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

Write a program that reads student scores, gets the best score, and then assigns

ID: 3545002 • Letter: W

Question

Write a program 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 otherwise.

The program prompts the user to enter the total number of students, then prompts the user to enter

all of the scores and save them in the array you defined, 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 score is 40 and grade is C

Student 1 score is 55 and grade is B

Student 2 score is 70 and grade is A

Student 3 score is 58 and grade is B

Explanation / Answer

import java.lang.Math;

import java.util.Scanner;

public class grading {


public static void main(String[] args){

int highest=0;

Scanner input=new Scanner(System.in);

System.out.println("Enter number of students");

int i = input.nextInt();

int[] marks = new int[i] ;

String[] grade = new String[i];

System.out.println("Please enter the marks");

for(int a =0; a<i;a++){

marks[a] = input.nextInt();

highest = Math.max(highest,marks[a]);

}

for(int a =0; a<i;a++){

if(marks[a]>=highest-10){

grade[a] = "A";

}

else if(marks[a]>=highest-20){

grade[a] = "B";

}

else if(marks[a]>=highest-30){

grade[a] = "C";

}

else if(marks[a]>=highest-40){

grade[a] = "D";

}

else{

grade[a] = "F";

}

}

for(int a =0; a<i;a++){

System.out.println("Student "+a+" score is "+marks[a]+" and Grade is "+grade[a]);

}

}

}

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