Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

菜鸟弱弱地问。。。。1004

Posted by Java_ at 2005-04-05 21:57:23 on Problem 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator