编写程序: 从键盘上读入一个学生成绩,存放在变量score中,根据score的 值输出其对应的成绩等级: score>=90 等级: A 70<=score<90 等级: B 60<=score<70 等级: C score<60 等级: D
package com.company;
public class lzx {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入该学生的成绩:");
int score = scanner.nextInt() / 10;
switch (score) {
case 10:
case 9:
System.out.println("成绩评级:A");
break;
case 8:
case 7:
System.out.println("成绩评级:B");
break;
case 6:
System.out.println("成绩评级:C");
break;
default:
System.out.println("成绩评级:D");
break;
}
}
}
|