I got a request from my site readers who is a student of the final year in BCA and is a java beginner about how to write a program in java programming language to check whether the number is Odd or Even.
This is a simple java program to validate the entered number is Odd OR even. Copy the below program and execute with the help o-f java compiler to see the output. At the end of this tutorial, I have shared some execution results of this program.
public static void main(String args)
System.out.println("Enter an integer to check if it is odd or even:");
Scanner in = new Scanner(System.in);
x = in.nextInt();
if ( x % 2 == 0 )
System.out.println("This is a Even number.");
System.out.println("This is a Odd number.");
Enter an integer to check if it is odd or even:
This is a Odd number.
If you are facing any issue to run the above program, then feel free to add your comment in the below comment section.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: how to find odd even number in java, Java programs, Java programs with examples, Java programs with output, java tutorial, Java tutorials, Odd Even Program in Java, simple java program to find odd even number