Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in Java, that reads student scores, gets the best score, and the

ID: 3632123 • Letter: W

Question


Write a program in Java, that reads student scores, gets the best score, and then assigns grades based on
the following scheme:
Grade is A if score is >= best -10
Grade is B if score is >= best -20
Grade is C if score is >= best -30
Grade is D if score is >= best -40
Grade is F if score is >= best -50
The program prompts the user to enter the total number of students, then prompts the user to
enter all of the scores, and concludes by displaying the grades.

Here is a sample run:
Enter the number of students: 4
Enter 4 scores: 40 55 70 58
Student 0 scores is 40 and grade is C
Student 1 scores is 55 and grade is B
Student 2 scores is 70 and grade is A
Student 3 scores is 58 and grade is B

Explanation / Answer

Hope this helps,

please rate LifeSaver!

import java.util.ArrayList;
import java.util.Scanner;


public class studentScores {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter number of students");
int num = sc.nextInt();
ArrayList<Integer>scores = new ArrayList<Integer>();

System.out.println("Enter "+num+" scores");

for(int i =0;i<num;i++){
scores.add(sc.nextInt());
}

//used to sort the scores list
for(int i = 1; i < scores.size(); ++i){
for(int j = i; j >= 1; --j){

if(scores.get(j-1) > scores.get(j))
{
int temp =scores.get(j);
scores.set(j, scores.get(j-1));
scores.set(j-1, temp);
}
else
break;
}
}

 


int a = scores.get(scores.size()-1)-10;
int b = scores.get(scores.size()-1)-20;
int c = scores.get(scores.size()-1)-30;
int d = scores.get(scores.size()-1)-40;

for(int i =0; i<scores.size();i++){
if(scores.get(i)>=a){
System.out.println("Student "+i+" score is "+scores.get(i)+" and grade is A");
}
else if(scores.get(i)<a && scores.get(i)>=b){
System.out.println("Student "+i+" score is "+scores.get(i)+" and grade is B");
}
else if(scores.get(i)<b && scores.get(i)>=c){
System.out.println("Student "+i+" score is "+scores.get(i)+" and grade is C");
}
else if(scores.get(i)<c && scores.get(i)>=d){
System.out.println("Student "+i+" score is "+scores.get(i)+" and grade is D");
}
else if(scores.get(i)<d){
System.out.println("Student "+i+" score is "+scores.get(i)+" and grade is F");
}
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote