假设某学校对成绩的判断标准是:不低于 90,可以评为优秀;低于 90 但不低于 80,可以评为良好;低于 80 但不低于 60,可以评为中等;否则评为差。
public static void main(String[] args) { System.out.println("请输入考试成绩:"); Scanner input = new Scanner(System.in); int score = input.nextInt(); // 接收键盘输入数据 if (score >= 90) { // 考试成绩>=90 System.out.println("优秀"); } else if (score >= 80) { // 90>考试成绩>=80 System.out.println("良好"); } else if (score >= 60) { // 80>考试成绩>=60 System.out.println("中等"); } else { // 考试成绩<60 System.out.println("差"); } }