Java Programming if-else Statement - if else program in java
if-else program in java using a scanner
import java.util.Scanner;
class IfElse {
public static void main(String[] args) {
int marks , passingM ;
passingM = 40;
Scanner input = new Scanner(System.in);
System.out.println("Input marks scored by you");
marks = input.nextInt();
if (marks >= passingM ) {
System.out.println("You passed the exam.");
}
else {
System.out.println("Unfortunately, you failed to pass the exam.");
}
}
}