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