Skip to content
Exercises · Q7

Q.Write a Java program using an if...else if ladder that reads a student's marks (0–100) and prints the division: 75 and above → "Distinction", 60–74 → "First Division", 35–59 → "Pass", below 35 → "Fail".

ChseodishaTextbookSubjectiveImportance★★★★★est
54% · 7/13 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Complete program:

import java.util.Scanner;

public class Division {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter marks (0-100): ");
        int marks = sc.nextInt();

        if (marks >= 75) {
            System.out.println("Distinction");
        } else if (marks >= 60) {
            System.out.println("First Division");
        } else if (marks >= 35) {
            System.out.println("Pass");
        } else {
            System.out.println("Fail");
        }
    }
}

Why the order matters. The ladder is checked top to bottom, and the first true condition wins. So the strictest test (>= 75) must come first. If we wrongly put >= 35 first, then a mark of 80 would satisfy >= 35 immediately and print "Pass" — never reaching "Distinction". Ordering from the highest cut-off downward guarantees each mark lands in exactly one band. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.