Newer
Older
OEResource sharing
committed
public class CalculateGradesStatisticsSolution {
private static void calculateGradesStatistics(int[] grades) {
int countA = 0, countB = 0, countC = 0, countD = 0, countF = 0;
for (int grade : grades) {
switch (grade / 10) {
case 10, 9:
countA++;
break;
case 8:
countB++;
break;
case 7:
countC++;
break;
case 6:
countD++;
break;
default:
countF++;
break;
}
}
System.out.println("A: " + countA + "\n"
+ "B: " + countB + "\n"
+ "C: " + countC + "\n"
+ "D: " + countD + "\n"
+ "F: " + countF);
}
}