forked from angiejones/java-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestResults.java
More file actions
40 lines (33 loc) · 834 Bytes
/
Copy pathTestResults.java
File metadata and controls
40 lines (33 loc) · 834 Bytes
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
40
package chapter3;
import java.util.Scanner;
/*
* IF-ELSE-IF
* Display the letter grade for a student based on their test score.
*/
public class TestResults {
public static void main(String args[]){
//Get the test score
System.out.println("Enter your test score:");
Scanner scanner = new Scanner(System.in);
double score = scanner.nextDouble();
scanner.close();
//Determine the letter grade
char grade;
if(score < 60){
grade = 'F';
}
else if(score < 70){
grade = 'D';
}
else if(score < 80){
grade = 'C';
}
else if(score < 90){
grade = 'B';
}
else{
grade = 'A';
}
System.out.println("Your grade is " + grade);
}
}