This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit 4b78750a authored by OEResource sharing's avatar OEResource sharing
Browse files

Update file CalculateGradesStatisticsSolution.java for resource with id:...

Update file CalculateGradesStatisticsSolution.java for resource with id: 1ae9846a-15b6-4cc7-bd9a-1e516980aca9
parent 0f9ef110
Branches
No related merge requests found
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);
}
}
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);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment