1. CONDITION STATEMENTS
If-else,
1. WAJP to compare 2 nos with three conditions
(i) a=b Equal
(ii) a>b Greater
(iii) a<b Lesser
import java.util.Scanner;
public class Compare
{
public static void main(String[] args)
{
Scanner s =new Scanner(System.in);
int a = s.nextInt();
int b = s.nextInt();
if(a == b)
{
System.out.println("Equal");
}
else if(a > b)
{
System.out.println("a is greater");
}
else
{
System.out.println("a is lesser");
}
}
}
2. 2. WAJP to check if a number is even or odd
import java.util.Scanner;
public class EvenOdd
{
public static void main (String[] args)
{
Scanner s = new Scanner(System.in);
int x = s.nextInt();
if (x % 2 == 0)
{
System.out.println("Even");
}
else
{
System.out.println("Odd");
}
}
}