Check Pass or Fail

This program checks if a student has passed or failed based on marks.

Problem Statement

Write a Java program that checks if marks are above 40 for pass, else fail.

Source Code

1 public class PassFail {
2 public static void main(String[] args) {
3 int marks = 35;
4 if(marks >= 40) {
5 System.out.println("Pass - Eduinq");
6 } else {
7 System.out.println("Fail - Eduinq");
8 }
9 }
10 }

Program Output

Fail - Eduinq

Explanation

The program declares marks and checks if they are greater than or equal to 40. If true, it prints Pass; otherwise, Fail. This simple if-else structure is commonly used in grading systems. It demonstrates how conditional statements can be applied to real-world scenarios like academic evaluation, where thresholds determine outcomes. Shows how if-else can be used for pass/fail checks.

Quick Links to Explore