Exam Result Classification

This program classifies exam results based on marks and attendance using nested if.

Problem Statement

Write a Java program that classifies exam results based on marks and attendance.

Source Code

1 public class ExamResult {
2 public static void main(String[] args) {
3 int marks = 65;
4 int attendance = 80;
5 if(attendance >= 75) {
6 if(marks >= 50) {
7 System.out.println("Pass - Eduinq");
8 } else {
9 System.out.println("Fail due to low marks - Eduinq");
10 }
11 } else {
12 System.out.println("Fail due to low attendance - Eduinq");
13 }
14 }
15 }

Program Output

Pass - Eduinq

Explanation

The program first checks if attendance is at least 75%. - If true, it then checks if marks are at least 50. - Only if both conditions are satisfied, the student passes. - Otherwise, it prints the reason for failure. - This demonstrates nested if statements where one condition depends on another, useful for multi-factor result classification in academic contexts. Conclusion: Shows how nested if can classify exam results based on multiple factors.

Quick Links to Explore