poj1004

package easy;


import java.util.Scanner;


/** 
 * poj1004 easy
 * @author NC
 */
public class Poj1004 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        if(scan.hasNext()){
            float sum = 0f;
            float balance;
            for(int i=0;i<12;i++){
                balance = scan.nextFloat();
                sum = sum +balance;
            }
            int average = Math.round(sum/12*100);//4舍5入
            System.out.printf("$%.2f",average/100.0);//两位小数
        }
    }
}

你可能感兴趣的:(java)