-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestResults.java
More file actions
39 lines (32 loc) · 1.11 KB
/
TestResults.java
File metadata and controls
39 lines (32 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//TestResults.java
import javax.swing.JOptionPane; // Needed for JOptionPane
/**
This program asks the user to enter a numberic test
score and displays a letter grade for the score. The
program uses an if-else-if statement to determine
the letter grade.
*/
public class TestResults
{
public static void main(String[] args)
{
int testScore; // Numberic test score
String input; // To hold the user's input
// Get the numeric test score.
input = JOptionPane.showInputDialog("Enter your numeric " +
"test score and I will tell you the grade: ");
testScore = Integer.parseInt(input);
// Display the grade.
if (testScore < 60)
JOptionPane.showMessageDialog(null, "Your grade is F.");
else if (testScore < 70)
JOptionPane.showMessageDialog(null, "Your grade is D.");
else if (testScore < 80)
JOptionPane.showMessageDialog(null, "Your grade is C.");
else if (testScore < 90)
JOptionPane.showMessageDialog(null, "Your grade is B.");
else
JOptionPane.showMessageDialog(null, "Your grade is A.");
System.exit(0);
}
}