Even OR Odd program in Java

Views: 89   

Java program which takes a number as input and Prints its even number or odd number


import java.util.Scanner;

public class IfConditionEvenOrOdd {

    public static void main(String[] args) {
        System.out.println("Please enter the number:");
        Scanner in = new Scanner(System.in);
        int i = in.nextInt();
        in.close();

        if (i % 2 == 0) {
            System.out.println("Its an even number");
        } else {
            System.out.println("It's an odd number");
        }
    }

}

Output:

Please enter the number:
23
It's an odd number
On By