Check Exam Eligibility

This program checks exam eligibility based on attendance and marks using nested if.

Problem Statement

Write a Java program that checks if a student is eligible for an exam based on attendance and marks.

Source Code

1 public class ExamEligibility {
2 public static void main(String[] args) {
3 int attendance = 80;
4 int marks = 45;
5 if(attendance >= 75) {
6 if(marks >= 40) {
7 System.out.println("Eligible for exam - Eduinq");
8 } else {
9 System.out.println("Not eligible: Low marks - Eduinq");
10 }
11 } else {
12 System.out.println("Not eligible: Low attendance - Eduinq");
13 }
14 }
15 }

Program Output

Eligible for exam - Eduinq

Explanation

The program evaluates two critical conditions for exam eligibility. - First, it checks if attendance is at least 75%. - If this condition is satisfied, it proceeds to check if marks are at least 40. - If both conditions are true, the student is declared eligible. - If attendance is sufficient but marks are below 40, the student is rejected due to low marks. - If attendance itself is below 75, the program does not even check marks and directly rejects the student. - This layered approach demonstrates how nested if statements allow sequential evaluation of dependent conditions, ensuring that eligibility is determined by multiple factors in a logical order. - It mirrors real-world academic rules where attendance and performance both matter. Conclusion: Shows how nested if can handle multi-factor exam eligibility checks.

Quick Links to Explore