Check Grading System with Ranges
This program assigns grades based on marks ranges.
Problem Statement
Write a Java program that assigns grades based on marks ranges.
Source Code
| 1 | public class GradingSystem { |
| 2 | public static void main(String[] args) { |
| 3 | int marks = 67; |
| 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: C - Eduinq
Explanation
The program uses an if-else ladder to assign grades based on ranges of marks. - 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 ensures that only one grade is assigned per student. - It demonstrates how if-else ladders can classify values into ranges efficiently. Conclusion: Shows how grading systems can be implemented using if-else ladders.