Check Whether Input Number Is Even Or Odd | Java Programs

Output:

*** Whether Number Is EVEN Or ODD ***

Enter an Integer number: 8
8 is an EVEN number.

Click Here For Java Online Compiler

Solution:

import java.util.Scanner;

public class CheckOddEven {

    public static void main(String args[]) {
        int num;
        System.out.println("*** Whether Number Is EVEN Or ODD ***" + "\n");
        System.out.print("Enter an Integer number: ");

        Scanner input = new Scanner(System.in);
        num = input.nextInt();

        if (num % 2 == 0) {
            System.out.println(num + " is an EVEN number.");
        } else {
            System.out.println(num + " is an Odd number.");
        }
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon