Answer:
public class nnn {
public static void main(String[] args) {
int [] examScores = {31, 70, 92, 5, 47, 88, 81, 73, 51, 76, 80, 90, 55, 23, 43,98,36,87,22,61, 19,69,26,82,89,99, 71,59,49,64};
int zeroTo19 = 0;
int nineteenTo39 = 0;
int fortyTo59 = 0;
int sixtyTo79 = 0;
int eightyTo100 = 0;
for(int i =0; i<examScores.length; i++){
if(examScores[i]<=19){
zeroTo19++;
}
else if(examScores[i]>19&&examScores[i]<=39){
nineteenTo39++;
}
else if(examScores[i]>39&&examScores[i]<=59){
fortyTo59++;
}
else if(examScores[i]>59&&examScores[i]<=79){
sixtyTo79++;
}
else {
eightyTo100++;
}
}
System.out.println("0 - 19 is "+zeroTo19);
System.out.println("20 - 39 is "+nineteenTo39);
System.out.println("40 - 59 is "+fortyTo59);
System.out.println("60 - 79 is "+sixtyTo79);
System.out.println("80 - 100 is "+eightyTo100);
}
}
Explanation:
- This has been solved with Java
- Create an array of the exam scores
- Create new variables for each of the score range
- Use multiple if statements as u loop through the array to determine the range of scores
- Finally outside the loop print them variables out