Grade Calculator
Objective
To get more practice with using if statements, conditions, and blocks.
Task
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.
Details
- 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.
Sample Run
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+.
Submitting
When your program works, email the code to ifinlay@umw.edu.
Copyright ©
2024
Ian Finlayson | Licensed under a Creative Commons BY-NC-SA 4.0 License.