Java program that compute the average test score for a student and assign the appropriate letter grade
###### Posted by Samath
Last Updated: January 17, 2024

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)
{
}
else if (average >= 0 && average <= 59)
{
}
}
}
```

###### C++ program that accepts a grade from a user and outputs a letter grade
Samath | Nov 04, 2014
###### Student Class in Java
Samath | Jan 20, 2024
###### C++ program that calculates the average of three test scores
Samath | Nov 15, 2014
###### C Program to calculate sum of 5 subjects, calculate percentage and grade
Samath | Jan 02, 2017
###### Student Management System in C++
Samath | Jan 08, 2021
###### C++ Printing Student Table Using iomanip
Samath | Jan 04, 2017
###### JavaScript program that capitalizes the first letter of each word in a string
SceDev | Feb 24, 2024
###### How do you write a query to find the average value of a numeric column?
JackBrn | Jun 20, 2024
###### How do you use the AVG function to calculate the average value of a numeric column?
NickCrt | Jul 22, 2024
###### Java program that uses a loop to compute the sum of all even numbers between 2 and 100 (inclusive)
Samath | Apr 03, 2022
###### How do you use the HASHBYTES function to compute a hash value for a given input?
FrankMl | Jul 27, 2024
###### Assign seats for a commercial airplane in C++
Samath | Jan 06, 2021
###### How do you use the ROW_NUMBER function with PARTITION BY to assign sequential numbers?
PaulAnd | Jun 21, 2024
###### C Program to Compute sum of the array elements using pointers
Samath | Jan 02, 2017