您的位置:首页 > 其它

POJ 1004 Financial Management

2012-04-23 12:47 381 查看
FinancialManagement

TimeLimit:1000MSMemoryLimit:10000K
TotalSubmissions:87085Accepted:42411
Description
Larrygraduatedthisyearandfinallyhasajob.He'smakingalotofmoney,butsomehowneverseemstohaveenough.Larryhasdecidedthatheneedstograbholdofhisfinancialportfolioandsolvehisfinancingproblems.The
firststepistofigureoutwhat'sbeengoingonwithhismoney.Larryhashisbankaccountstatementsandwantstoseehowmuchmoneyhehas.HelpLarrybywritingaprogramtotakehisclosingbalancefromeachofthepasttwelvemonthsandcalculatehis
averageaccountbalance.
Input
Theinputwillbetwelvelines.Eachlinewillcontaintheclosingbalanceofhisbankaccountforaparticularmonth.Eachnumberwillbepositiveanddisplayedtothepenny.Nodollarsignwillbeincluded.

Output
Theoutputwillbeasinglenumber,theaverage(mean)oftheclosingbalancesforthetwelvemonths.Itwillberoundedtothenearestpenny,precededimmediatelybyadollarsign,andfollowedbytheend-of-line.Therewillbe
nootherspacesorcharactersintheoutput.
SampleInput
100.00
489.12
12454.12
1234.10
823.05
109.20
5.27
1542.25
839.18
83.99
1295.01
1.75

SampleOutput
$1581.42


java代码如下:


importjava.util.Scanner;
publicclassMain{
publicstaticvoidmain(String[]args){
Scannerin=newScanner(System.in);
doublea[]=newdouble[12];
doublesum=0.0;
for(inti=0;i<12;i++){
a[i]=in.nextDouble();
sum+=a[i];
}
sum/=12;
System.out.printf("$%.2f\n",sum);
}
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: