Java Program To Check a Number is Even or Odd

By | July 2, 2019

Task: Write a Java Program To Check a Number is Even or Odd

The Source Code for Even Odd Checking Java Program

/*
  Write a Java Program for checking a 
  number is even or odd
 */
package evenodd;
/**
 * @author www.EasyCodeBook.com
 */
import java.util.Scanner; 
public class EvenOdd {
    public static void main(String[] args) {
     int number ;
Scanner input = new Scanner(System.in);
System.out.print("Enter a number for checking Even / Odd:");
number = input.nextInt();
if(number % 2==0)
System.out.println(number + " is Even number.");
else
System.out.println(number + " is Odd number");
}
} 
Sample Run and Output of  Even Odd Checking Program in Java

Enter a number for checking Even / Odd:150
150 is Even number.

Java Program for Checking a Number is Even or Odd

Java Program for Checking a Number is Even or Odd

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *