Question: Write a program called TestAvgGrade.java. The program should ask the user to enter five test scores, and then assign the value entered to the variables.

Write a program called TestAvgGrade.java. The program should ask the user to enter five test scores, and then assign the value entered to the variables. The program should display a letter grade for each score and the average test scores. Use the grading scheme in the following table. Score Letter Grade 90-100 A 80-89 B 70-79 C 60-69 D Below 60 F

This what I have...

import javax.swing.JOptionPane;

public class TestAvgGrade { public static void main(String[] args) { // Declare variables to hold user input String input1, input2, input3, input4, input5; // Declare variables to store converted user input double score1, score2, score3, score4, score5, average; // Prompt user for 5 test scores input1 = JOptionPane.showInputDialog(null, "Enter score 1:"); input2 = JOptionPane.showInputDialog(null, "Enter score 2:"); input3 = JOptionPane.showInputDialog(null, "Enter score 3:"); input4 = JOptionPane.showInputDialog(null, "Enter score 4:"); input5 = JOptionPane.showInputDialog(null, "Enter score 5:"); // Convert test scores to data type double score1 = Double.parseDouble(input1); score2 = Double.parseDouble(input2); score3 = Double.parseDouble(input3); score4 = Double.parseDouble(input4); score5 = Double.parseDouble(input5); // Calculate test score average average = (score1 + score2 + score3 + score4 + score5) / 5; /* Design a decision structure to determine a letter grade that corresponds to the average.*/ if (average <= 100){ if(average >= 90){ JOptionPane.showMessageDialog(null, "Your average is " + average + " or A"); } else if(average >= 80){ JOptionPane.showMessageDialog(null, "Your average is " + average + " or B"); } else if(average >= 70){ JOptionPane.showMessageDialog(null, "Your average is " + average + " or C"); } else if(average >= 60){ JOptionPane.showMessageDialog(null, "Your average is " + average + " or D"); } else if(average < 60) { JOptionPane.showMessageDialog(null, "Your average is " + average + " or F"); } } else { JOptionPane.showMessageDialog(null, "Your average is out of bounds, check test scores."); } }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!