依次输入10个学生成绩,判断学生(优秀、良好、中等、及格、不及格)并计算人数。(java实现)
import java.util.*;
public class T1_3 {
public static void main(String[] args){
int i,count0=0,count1=0,count2=0,count3=0,count4=0,count5=0;
//int grade=0;
System.out.println("请输入10个0-100之间的数:");
Scanner sc = new Scanner(System.in);
int[] arr = new int[10];
for(i=0;i<9;i++)
{
arr[i] = sc.nextInt();
int grade = arr[i]/10;
switch(grade)
{
case 10:count0++;break;
case 9:count1++;break;
case 8:count2++;break;
case 7:count3++;break;
case 6:count4++;break;
default:count5++;break;
}
}
System.out.println(count0+count1+"个优秀。");
System.out.println(count2+"个良好。");
System.out.println(count3+"个中等。");
System.out.println(count4+"个及格。");
System.out.println(count5+"个不及格。");
}
}