poj1004的java实现




import java.text.DecimalFormat;
import java.util.Scanner;


public class Testpoj1004 {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
float value = 0 ;

for(int i = 0 ; i < 12 ; ++i ){
 
value += Float.valueOf(scanner.nextLine()).floatValue();
}

value = value / 12;

DecimalFormat df = new DecimalFormat(".00"); 

String str = df.format(value);

System.out.println("$" +str);

}
}

posted @ 2013-04-16 20:30  xinyuyuanm  阅读(173)  评论(0编辑  收藏  举报