Java program that compute the average test score for a student and assign the appropriate letter grade Posted by Samath Last Updated: December 21, 2014 15574

Write a program that reads a student’s name together with his or her test scores. The program should then compute the average test score for each student and assign the appropriate grade. The grade scale is as follows: 90-100,A; 80-89,B; 70-79,C; 60-69,D; 0-59,F.

Your program must use the following methods:

a.  A value-returning method, calculateAverage, to determine and return the average of five test scores for each student. Use a loop to read and sum the five test scores. (This method does not output the average test score. That task must be done in the method main.)

b. A value-returning method, calculateGrade, to determine and return each student’s grade. (This method does not output the grade. That task must be done in the
method main.)

Solution:

```package testScores;
import java.util.Scanner;

public class testScores {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String name;
float avg;

System.out.print("Enter student's name: ");
name = scan.nextLine();

avg = calculateAverage();

System.out.print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
System.out.print("\nName: "+name);
System.out.print("\nAverage: "+avg);
System.out.print("\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");

}

public static float calculateAverage()
{
float grd;
float sum = 0;
float average = 0;
Scanner scan = new Scanner(System.in);
for(int i=0;i<5;i++)
{
grd = scan.nextFloat();
sum = sum + grd;
}

average = sum / 5;

return average;
}

{
if (average >= 90 && average <= 100)
{
}
else if (average >= 80 && average <= 89)
{
}
else if (average >= 70 && average <= 79)
{
}
else if (average >= 60 && average <= 69)
{