Exam Grading System
This program assigns grades based on marks using if-else ladder.
Problem Statement
Write a Java program that assigns grades based on marks.
Source Code
| 1 | public class ExamGrading { |
| 2 | public static void main(String[] args) { |
| 3 | int marks = 72; |
| 4 | if(marks >= 90) { |
| 5 | System.out.println("Grade: A+ - Eduinq"); |
| 6 | } else if(marks >= 80) { |
| 7 | System.out.println("Grade: A - Eduinq"); |
| 8 | } else if(marks >= 70) { |
| 9 | System.out.println("Grade: B - Eduinq"); |
| 10 | } else if(marks >= 60) { |
| 11 | System.out.println("Grade: C - Eduinq"); |
| 12 | } else if(marks >= 50) { |
| 13 | System.out.println("Grade: D - Eduinq"); |
| 14 | } else { |
| 15 | System.out.println("Grade: F - Eduinq"); |
| 16 | } |
| 17 | } |
| 18 | } |
Program Output
Grade: B - Eduinq
Explanation
The program uses an if-else ladder to assign grades based on marks ranges. Each condition checks if marks fall within a specific range, starting from the highest grade. If none of the higher conditions are true, the program falls through to lower grades. This demonstrates how if-else ladders can classify values into ranges efficiently, useful in academic grading systems. Shows how exam grading can be implemented using if-else ladder.