Question: import java.util.Scanner; public class Exer int [ ] scores = new int [ numOfStudents ] ; System.out.print ( Enter + numOfStudents +

import java.util.Scanner;
public class Exer
int[] scores = new int[numOfStudents];
System.out.print("Enter "+ numOfStudents +" scores: ");
for (int i =0; i < numOfStudents; i++){
scores[i]= input.nextInt();
}
int bestScore = findBestScore(scores);
for (int i =0; i < scores.length; i++){
System.out.print("Student "+ i +" score is "+ scores[i]+" and grade is ");
printGrade(scores[i], bestScore);
}
input.close();
}
public static int findBestScore(int[] scores){
int best = scores[0];
for (int score : scores){
if (score > best){
best = score;
}
}
return best;
}
public static void printGrade(int score, int best){
if (score >= best -10){
System.out.println("A");
} else if (score >= best -20){
System.out.println("B");
} else if (score >= best -30){
System.out.println("C");
} else if (score >= best -40){
System.out.println("D");
} else {
System.out.println("F");
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!