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

Write a program that asks the user to enter five test scores. The program should

ID: 671561 • Letter: W

Question

Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program:   calcAverage—This method should accept five test scores as arguments and return the average of the scores.   determineGrade—This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale: Score 90–100  A 80–89 B 70–79 C 60–69 D Below 60 F   Letter Grade A B C D F

Explanation / Answer

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Scores
{
   public static char getGrade(int score)
   {
       char grade;
       if(score<=100 && score>=90)
           grade = 'A';
       else if(score<=89 && score>=80)
           grade = 'B';
       else if(score<=79 && score>=70)
           grade = 'C';
       else if(score<=69 && score>=60)
           grade = 'D';
       else
           grade = 'F';
      
       return grade;
          
   }
  
   public static double getAvg(int[] scores)
   {
       int sum = 0;
       for(int i=0;i<5;i++)
           sum = sum+scores[i];
      
       return sum/5.0;
   }
  
   public static void main (String[] args) throws java.lang.Exception
   {
       Scanner input = new Scanner(System.in);
       int[] scores = new int[5];
      
       for(int i=0;i<5;i++)
       {
           System.out.println("Input test score " + (i+1) + " : ");
           scores[i] = input.nextInt();
       }
      
   }
}

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