题解 | #学生基本信息输入输出#

学生基本信息输入输出

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);
    }
}
全部评论

相关推荐

11 收藏 评论
分享
牛客网
牛客企业服务