017-001-001
Conditional Branching: Grade Checker Program
Easy
Problem Description
conditional branching: Grade Checker Program
Learning Objective: Understand how to control program flow with conditional branching using if-else if-else statements
In this problem, you will create a program that reads an integer score (0-100) from standard input, uses if-else if-else statements to determine the grade (A through F) based on the score, and displays the result to standard output.
Create program to determine grade based on score. Learn how to control program flow by executing different processes based on conditions.
Understanding with Concrete Examples
Example 1: Excellent Grade (95 points)
- Input:
95 - Condition Check:
95 >= 90→ true (determined by first condition) - Grade Result: "A"
- Output: "Grade Result:" "Score: 95" "Grade: A"
Example 2: Middle Grade (75 points)
- Input:
75 - Condition Check:
75 >= 90→ false,75 >= 80→ false,75 >= 70→ true - Grade Result: "C" (determined by 3rd condition)
- Output: "Grade Result:" "Score: 75" "Grade: C"
Example 3: Boundary Value (exactly 90 points)
- Input:
90 - Condition Check:
90 >= 90→ true (boundary value included) - Grade Result: "A"
- Output: "Grade Result:" "Score: 90" "Grade: A"
Input
Line 1: Score (integer, 0-100)
Output
Grade Result:
Score: [score]
Grade: [grade]
```java
Grade criteria:
- 90 or above: A
- 80 or above and below 90: B
- 70 or above and below 80: C
- 60 or above and below 70: D
- Below 60: F
**Key Point**: <a href="https://javadrill.tech/problems/005/001">if statement</a> conditions are evaluated **in order from top to bottom**. The first condition that becomes true has its block executed, and remaining conditions are skipped.
Test Cases
※ Output examples follow programming industry standards
Input:
95
Expected Output:
Grade Result: Score: 95 Grade: A
Input:
75
Expected Output:
Grade Result: Score: 75 Grade: C
Input:
90
Expected Output:
Grade Result: Score: 90 Grade: A
Input:
59
Expected Output:
Grade Result: Score: 59 Grade: F
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 6 free executions remaining
