0
0
Javaprogramming~15 mins

Else–if ladder in Java - Mini Project: Build & Apply

Choose your learning style9 modes available
Else-if ladder
📖 Scenario: You are creating a simple program that assigns a grade based on a student's score.
🎯 Goal: Build a Java program that uses an else-if ladder to print the correct grade for a given score.
📋 What You'll Learn
Create an integer variable called score with the exact value 85.
Create an integer variable called passingScore with the exact value 50.
Use an else-if ladder with the variable score to assign grades:
90 and above is Grade A
80 to 89 is Grade B
70 to 79 is Grade C
60 to 69 is Grade D
50 to 59 is Grade E
Below 50 is Fail.
Print the grade using System.out.println.
💡 Why This Matters
🌍 Real World
Grading systems in schools or colleges use similar logic to assign letter grades based on numeric scores.
💼 Career
Understanding conditional statements like else-if ladders is essential for decision-making in software development.
Progress0 / 4 steps
1
Create the score variable
Create an integer variable called score and set it to 85.
Java
Need a hint?

Use int score = 85; inside the main method.

2
Create the passingScore variable
Add an integer variable called passingScore and set it to 50 below the score variable.
Java
Need a hint?

Declare int passingScore = 50; just after score.

3
Write the else-if ladder for grades
Write an else-if ladder using the variable score to assign grades as follows: if score >= 90, print Grade A; else if score >= 80, print Grade B; else if score >= 70, print Grade C; else if score >= 60, print Grade D; else if score >= 50, print Grade E; else print Fail. Use System.out.println inside each block.
Java
Need a hint?

Use if, multiple else if, and a final else to cover all score ranges.

4
Print the grade result
Run the program to print the grade for the score 85. The output should be Grade B.
Java
Need a hint?

Run the program and check the console output.