Java if else program

                                                 Java if else program
// If else in Java-Java if else program uses if else to execute statement(s)
import java.util.Scanner;

class JavaCondition
 {
  public static void main(String[] args)
{
    int marksScored, passingMarks;

    passingMarks = 36;

    Scanner input = new Scanner(System.in);
 
    System.out.println("Enter marks scored by you");    /* program ask the user to enter marks scored in exam

    marksScored = input.nextInt();

    if (marksScored >= passingMarks)     /* input marks are compared against minimum passing marks*/
 {
      System.out.println("You passed the exam");  /*"You passed the exam"  message is printed on screen if  user passed the exam*/
    }
    else {
      System.out.println("you failed to pass the exam");   /*"you failed to pass the exam"message is printed on screen if marks is below passing marks*/
    }
  }
}

Related Posts