Java经典编程题50道之五

利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示。

public class Example05 {

    public static void main(String[] args) {
        score(90);
    }

    public static void score(int n) {
        char s = n >= 90 ? 'A' : (n < 60 ? 'C' : 'B');
        System.out.println("该成绩等级为:" + s);
    }
}

原文地址:https://www.cnblogs.com/qubo520/p/6924566.html