NYOJ–72–Financial Management

來源:互聯網
上載者:User
Financial Management時間限制:3000 ms  |  記憶體限制:65535 KB難度:1
描述
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.

輸入
The input will be twelve lines. Each line will contain the closing balance of his bank account for a particular month. Each number will be positive and displayed to the penny. No dollar sign will be included.
輸出
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.
範例輸入
100.00489.1212454.121234.10823.05109.205.271542.25839.1883.991295.011.75
範例輸出
1581.42

 

 

import java.util.Scanner;public class rong {public static void main(String[] args) {// TODO Auto-generated method stubScanner input=new Scanner(System.in);while(input.hasNext()){float[] a = new float[12];    float b=0;    float  sum=0;    for(int i=0;i<12;i++){    a[i]=input.nextFloat();    sum+=a[i];    }    b=(float)sum/12;    System.out.printf("%.2f\n",b);}}}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.