Program To Check Whether the Number Is Even or Odd in Java .

Here In This Article will be saying that ,how to check whether this number is even or not in java programming language. and How to check Even or Odd Number…

Program to check whether the number is Odd Or Even by Taking User Input..

OddEven.java

import java.util.Scanner;
 class OddEven
 {
     public static void main(String args[])
 {
 int x;
 Scanner sc=new Scanner(System.in);

    System.out.print("Enter the Number:"); //take input by //user

       x=sc.nextInt();

 if(x%2==0)

    {

    System.out.print(" Number is even.");

    }
        else
   {
            System.out.print("Number is odd.");
       
        }    
     
      }
  
}
0Shares

Leave a Reply