import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int countA = 0;
int countB = 0;
int countC = 0;
int countD = 0;
int countE = 0;
for (int i = 1; i <= 10; i++) {
System.out.println("请输入第" + i + "个学生的成绩:");
int score = input.nextInt();
if (score >= 90 && score <= 100) {
countA++;
} else if (score >= 80 && score <= 89) {
countB++;
} else if (score >= 70 && score <= 79) {
countC++;
} else if (score >= 60 && score <= 69) {
countD++;
} else {
countE++;
}
}
System.out.println("A等成绩人数:" + countA);
System.out.println("B等成绩人数:" + countB);
System.out.println("C等成绩人数:" + countC);
System.out.println("D等成绩人数:" + countD);
System.out.println("E等成绩人数:" + countE);
}
}
不知道你这个问题是否已经解决, 如果还没有解决的话:count() 是一个聚合函数,对于返回的结果集,逐行判断,如果不为null,则累计值加1.