To get more practice with using if statements, conditions, and blocks.
For this lab, you will write a program to calculate the letter grade for this class given the numeric grade.
The ranges are listed on the syllabus as:
- [92, ∞): A
- [89, 92): A-
- [87, 89): B+
- [82, 87): B
- [79, 82): B-
- [77, 79): C+
- [72, 77): C
- [69, 72): C-
- [67, 69): D+
- [60, 67): D
- [0, 60): F
Input will be the number and output will be the letter grade that would earn.
- Prompt the user to enter their numeric grade.
- Read in the value using a Scanner.
- Use if and else if statements to check each condition for the user's grade.
- For each one, output the letter grade corresponding to the numeric grade.
- If the grade entered is less than 0, print an error message.
Below is a sample run of the program.
Values entered by the user are shown in bold face.
Please enter your grade: 87.5
Your grade is B+.
When your program works, email the code to email@example.com.
Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.