练习3(基础):
输入分数,打印等级(使用switch结构)
90-100 A
80-89 B
70-79 C
60-69 D
<60 E
package test3;
import java.util.Scanner;
/*
* 练习3(基础):
输入分数,打印等级(使用switch结构)
90-100 A
80-89 B
70-79 C
60-69 D
<60 E
*/
public class Score {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("请输入分数:");
int score = sc.nextInt();
System.out.println(score/10);
switch(score/10){//?????????为什么要/10
case 10:
case 9:
System.out.println("A");
break;
case 8:
System.out.println("B");
break;
case 7:
System.out.println("C");
break;
case 6:
System.out.println("D");
break;
case 5:
case 4:
case 3:
case 2:
case 1:
System.out.println("E");
break;
default:
System.out.println("输入错误");
}
}
}