package homework;
import java.util.Scanner;
public class CreditRating {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 测试数组
// int score[] = { 72, 89, 65, 58, 87, 91, 53, 82, 71, 93, 76, 68 };
int countA = 0, countB = 0, countC = 0, countD = 0, countE = 0;
int score[] = new int[12];
for (int i = 0; i < score.length; i++) {
System.out.print("请输入第" + (i + 1) + "个学生的成绩:");
score[i] = sc.nextInt();
if (score[i] > 90) {
countA++;
} else if (score[i] > 80 && score[i] <= 89) {
countB++;
} else if (score[i] > 70 && score[i] <= 79) {
countC++;
} else if (score[i] > 60 && score[i] <= 69) {
countD++;
} else {
countE++;
}
}
System.out.println("\n共有" + score.length + "人参加本次测试,测试结果分别为:");
for (int i = 0; i < score.length; i++) {
System.out.print(score[i] + " ");
}
System.out.println("\n\n其中A类学员" + countA + "人,B类学员" + countB + "人,C类学员" + countC + "人,D类学员" + countD + "人,E类学员"
+ countE + "人");
sc.close();
}
}
Java使用数组实现学分等级分类
最新推荐文章于 2023-04-11 21:49:18 发布