题解 | #学生基本信息输入输出#
学生基本信息输入输出
http://www.nowcoder.com/practice/58b6a69b4bf943b49d2cd3c15770b9fd
用
String.format("%.2f", d);
来四舍五入
public class Main {
public static void main(String[] args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String n = in.readLine();
String[] s = n.split("[;,]");
for (int i = 1; i < s.length;i++){
double d = Double.parseDouble(s[i]);
s[i] = String.format("%.2f", d);
}
System.out.printf("The each subject score of No. %s is %s, %s, %s.", s);
}
}