Here's a simple program about condition using "if" then followed by "else".
import java.util.*;
public class condition1{
public static void main(String[]args){
Scanner genioler = new Scanner(System.in);
System.out.print("Enter your age: ");
int age = genioler.nextInt();
if (age <= 17){
System.out.println("You are not allow to enter");
}
else {
System.out.println("You are allow to enter");
}
}
}
Note:
( == ) - equal
( > ) - greater than
( < ) - less than
( >= ) - greater than or equal
( <= ) - less than or equal
( != or <>) - not equal
( && ) - and
( || ) - or
No comments:
Post a Comment