| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
菜鸟弱弱地问。。。。1004如何在java控制格式输出,比如1004,应当如何输入
望指点一下
import java.io.* ;
import java.util.* ;
import java.text.* ;
public class Main
{
private static double sum = 0.0 ;
private static double temp ;
private static final int count = 12 ;
public static void main( String[] args) throws IOException
{
BufferedReader input = new BufferedReader( new InputStreamReader(System.in)) ;
NumberFormat dollars = NumberFormat.getInstance();
dollars.setMaximumFractionDigits(2);
for( int i = 1; i <= count ; i ++)
{
temp = Double.parseDouble(input.readLine()) ;
sum += temp ;
}
System.out.println("$"+dollars.format(sum/count*1.0)) ; ---1 这个不行
System.out.print("$"+sum/count) ; ---2 这个也不行
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator