标题: 今天学习switch语句 [打印本页] 作者: ruili 时间: 2015-8-23 21:41 标题: 今天学习switch语句 import java.util.*;
class CeShi {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入分数");
int x = sc.nextInt();
int y = x/10;
switch (y) {
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:
case 0:
System.out.println("E");
break;
default:
System.out.println("成绩输入错误,你是猪么");
break;
}
}
}