语言:java
public static void main(String[] args) {
//输入部分
//接收输入的类
Scanner scan = new Scanner(System.in);
//接收输入的字符串
String next = null;
//输入的成绩
int grade = 0;
System.out.println("请输入10个成绩,每输入一个回车一次");
//记录成功输入的数量
int num = 0;
int[] grades = new int[10];
while(num<10){
next = scan.nextLine();
try{
grade = Integer.parseInt(next);
}catch(NumberFormatException e){
System.out.println("输入的不是整数");
continue;
}
if(grade<0||grade>100){
System.out.println("输入的成绩不在0~100的范围内");
continue;
}
grades[num++] = grade;
}
//判断部分
for(int i=0;i<grades.length;i++){
switch(grades[i]){
case 100:
case 99:
case 98:
case 97:
case 96:
case 95:
case 94:
case 93:
case 92:
case 91:
case 90:
System.out.println(grades[i]+":优");
break;
case 89:
case 88:
case 87:
case 86:
case 85:
case 84:
case 83:
case 82:
case 81:
case 80:
System.out.println(grades[i]+":良好");
break;
case 79:
case 78:
case 77:
case 76:
case 75:
case 74:
case 73:
case 72:
case 71:
case 70:
case 69:
case 68:
case 67:
case 66:
case 65:
case 64:
case 63:
case 62:
case 61:
case 60:
System.out.println(grades[i]+":一般");
break;
default:
System.out.println(grades[i]+":差");
}
}
}
温馨提示:答案为网友推荐,仅供参考