Java Program to Check Whether Input Number Is Even or Odd

You are currently viewing Java Program to Check Whether Input Number Is Even or Odd

Java program to check whether input number is EVEN or ODD

import java.util.*;

/* Java Program to check whether entered number is EVEN or ODD */

public class j6 
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int num;

		//inpu
		System.out.print("Enter an integer number: ");
		num=sc.nextInt();
		
		//check EVEN or ODD
		if(num%2 ==0)
		{
			System.out.println(num +" is an EVEN number.");
		}
		else
		{
			System.out.println(num +" is an ODD number.");
		}
	}
}

Output

First Run:
Enter an integer number: 123
123 is an ODD number.

Second Run:
Enter an integer number: 166
166 is an EVEN number.

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply