您的位置:首页 > 其它

ZOJ-2476

2014-01-10 22:02 288 查看
又偷懒了。。JAVA里有format类,直接拿来用,省好多功夫

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

public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
while (n != 0)
{
double sum = 0;
while (n-- > 0)
{
String s = sc.nextLine();
double d = Double.parseDouble(s.substring(1)
.replaceAll(",", ""));
sum += d;
}
System.out.println("$"+ new DecimalFormat("#,##0.00").format(sum));
n = sc.nextInt();
sc.nextLine();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: