Hi i am doing a student grade lab where the student enters a grade they got on a test and they get a letter grade. My program only gives the user a F even if it should be another grade. This is my code.
strT1 = JOptionPane.showInputDialog("Enter 1st test score:");
std.test1 = Integer.parseInt(strT1);
Te1.setText("Your grade for test 1 is " + std.T1);
static char letterGrade(double g) {
if (g >= 90)
return 'A'; // 90 or above gets an A
else if (g >= 80)
return 'B'; // 80 to 89 gets a B
else if (g >= 65)
return 'C'; // 65 to 79 gets a C
else if (g >= 50)
return 'D'; // 50 to 64 gets a D
else
return 'F'; // anything else gets an F
}
public char T1 = letterGrade (test1);
Thanks for the help.