Java Program to Check Even and Odd Number

AS we all know, a number which is divided by 2 and don't leave any remainder is said to be even number. So here in Java programming too, we have applied the same logic to check whether a number is even or odd. In below program, for this we have use if-else conditional statement to print the result if a number entered is odd or even.

Source code for Even/Odd number checker Java Program

Java Program to check whether an entered number is even or odd.
Program by Codext.
import java.util.Scanner;

class EvenorOddNumber
   public static void main(String args[])
      int num;
      System.out.println("Enter the number to check if it is Even number or Odd number : ");
      Scanner in = new Scanner(;
      num = in.nextInt();

      if ( num % 2 == 0 )
         System.out.println("The number entered is Even.");
         System.out.println("The number entered is odd.");

Java Program Output to check Even or Odd Number


Post a Comment