Java从键盘输入学生成绩,输出成绩等级
(说明:百分制分数,90 ~100:A等级 70 ~90:B等级 60 ~70:C等级 小于60分D等级)
import java.util.Scanner;
public class exampleTest{
public static void main(String[] args) {
//成绩等级
Scanner scanner=new Scanner(System.in);
System.out.println("请输入学生的成绩:");
int score=scanner.nextInt();
switch (score/10) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
System.out.println("等级为D");
break;
case 6:
System.out.println("等级为C");
break;
case 7:
case 8:
System.out.println("等级为B");
break;
case 9:
case 10:
System.out.println("等级为A");
break;
}
}
}