Create a program that a professor can use to display a grade

Create a program that a professor can use to display a grade for any number of students. Each students grade is based on four test scores each worth 100 points. The program should total the student\'s test scores and then assign the appropriate grade using the information below. Display the student\'s number and grade in a message, such as \"Student 1\'s grade: A\"

B

Total points earned Grade
372-400 A
340-371

B

280-339 C
240-279 D
Below 240 F

Solution

GradeSystem.java

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


public class GradeSystem {


   public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
       ArrayList<Character> list = new ArrayList<Character>();
       int studennCount = 1;
       while(true){
           int sum = 0;
           int grade[] = new int[4];
           char gradeLetter = \'\\0\';
           System.out.println(\"Enter the student \"+studennCount+\" score: \");
           System.out.println(\"Enter 4 score: \");
           for(int i=0; i<4; i++){
               grade[i] = scan.nextInt();
               sum = grade[i] + sum;
           }
           if(sum >=372 && sum<=400){
               gradeLetter = \'A\';
           }
           else if(sum >=340 && sum<372){
               gradeLetter = \'B\';
           }
           else if(sum >=280 && sum<340){
               gradeLetter = \'C\';
                       }
           else if(sum >=240 && sum<280){
               gradeLetter = \'D\';
           }else{
               gradeLetter = \'F\';
           }
           list.add(gradeLetter);
           System.out.println(\"Do you want add antoher student details (y or n): \");
           char c = scan.next().charAt(0);
           studennCount++;
           if(c == \'n\' || c == \'N\'){
               break;
           }
       }
      
       for(int i=1; i<=list.size(); i++){
           System.out.println(\"Student \"+i+\"\'s grade: \"+list.get(i-1));
       }
   }

}

Output:

Enter the student 1 score:
Enter 4 score:
80 90 80 70
Do you want add antoher student details (y or n):
y
Enter the student 2 score:
Enter 4 score:
60 70 80 90
Do you want add antoher student details (y or n):
y
Enter the student 3 score:
Enter 4 score:
40 50 60 70
Do you want add antoher student details (y or n):
n
Student 1\'s grade: C
Student 2\'s grade: C
Student 3\'s grade: F

Create a program that a professor can use to display a grade for any number of students. Each students grade is based on four test scores each worth 100 points.
Create a program that a professor can use to display a grade for any number of students. Each students grade is based on four test scores each worth 100 points.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site