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);

}
}

你可能感兴趣的:(java实现)