I'm trying to write a code where after i write a code the program should display the average score and the letter grade. I can get the average but i can't get the letter . And im not sure if this code is right. tell me what i am doing wrong and how to fix it... here it is...
i
mport javax.swing.JOptionPane; // Needed for JOptionPane /**
This program demonstrates the if statement.
*/
public class TestScoresAndGrades
{
public static void main(String[] args)
{
double score1; // To hold score and letter grade #1
double score2; // To hold score and letter grade #2
double score3; // To hold score and letter grade #3
double average; // To hold the average score
String input; // To hold the user's input
// Get the first test score.
input = JOptionPane.showInputDialog("Enter score #1:");
score1 = Double.parseDouble(input);
// Get the second score.
input = JOptionPane.showInputDialog("Enter score #2:");
score2 = Double.parseDouble(input);
// Get the third test score.
input = JOptionPane.showInputDialog("Enter score #3:");
score3 = Double.parseDouble(input);
// Calculate the average score.
average = (score1 + score2 + score3) / 3.0;
// Display the average score.
JOptionPane.showMessageDialog(null,
"The average is " + average);
// Display the letter grade.
input = JOptionPane.showInputDislog(null,
"The letter grade is" + letter);
// If the score was greater than 95, let the user know
// that's a great score.
if (average > 95)
JOptionPane.showMessageDialog(null,
"That's a great score!");
System.exit(0);
}