005-001-012
Grade Ranking with if Statements
Medium
Problem Description
Grade Ranking with if Statements
In this problem, you will create a program that reads a test score from standard input, determines a grade rank (A/B/C/D) using chained if-else if-else statements, and displays the result to standard output.
Learning Objective: Understand chained if-else if-else for range-based conditions
Overview
Read a single integer score from standard input, determine its grade rank (A/B/C/D), and print the result.
Specifications
- Define
getGrade(int score)method - 90+:
A, 80+:B, 70+:C, below 70:D - Read the score with Scanner and print
Score: <score> -> Grade: <grade>
Input
<score>
One integer line (0–100)
Output Format
Score: <score> -> Grade: <grade>
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up