Zoj problem set-1048 Financial Management

Source: Internet
Author: User

Financial Management

Time Limit: 1 second memory limit: 32768 KB

Larry graduated this year and finally has a job. he's making a lot of money, but somehow never seems to have enough. larry has decided that he needs to grab hold of his financial portfolio and solve his financing problems. the first step is to figure out what's been going on with his money. larry has his bank account statements and wants to see how much money he has. help Larry by writing a program to take his closing balance from each of the past twelve months and calculate his average account balance.

Input Format:
The input will be twelve lines. each line will contain the closing balance of his bank account for a participant month. each number will be positive and displayed to the penny. no dollar sign will be removed ded.

Output Format:
The output will be a single number, the average (mean) of the closing balances for the twelve months. it will be rounded to the nearest penny, preceded immediately by a dollar sign, and followed by the end-of-line. there will be no other spaces or characters in the output.

Sample input:
100.00
489.12
12454.12
1234.10
823.05
109.20
5.27
1542.25
839.18
83.99
1295.01
1.75

Sample output:
$1581.42

Source: Mid-Atlantic USA 2001
 
1: # include <iostream>
2: # include <iomanip>
 
3:
 
4:Using NamespaceSTD;
 
5:
6:IntMain (Void)
 
7 :{
 
8:DoubleMoney;
 
9:DoubleSums = 0.0;
10:DoubleAverage = 0.0;
 
11:
 
12:For(IntI = 1; I <= 12; I ++)
 
13 :{
 
14: CIN> money;
15: Sum + = money;
 
16 :}
 
17:
 
18:// Calculate the average value
 
19: Average = sum/12;
20:
 
21:// Format the output
 
22: Average =Static_cast<Double> (Static_cast<Int> (Average * 100 + 0.5)/100;
 
23:
24: cout <"$"<Fixed<Setprecision (2) <average <Endl;
 
25:
 
26:Return0;
 
27 :}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.