Wednesday, 2 July 2014

Odd or Even Program in Java

Odd or Even Check using Java Code

A Java program to accept a number from keyboard and check whether it is Odd or Even

//A small java program to check the accepted number is Odd or Even
import java.util.Scanner;

public class OddEven {

    public static void main(String args[])
      int x;
      System.out.println("Enter an integer to check if it is odd or even ");
      Scanner in = new Scanner(;
      x = in.nextInt();

      if ( x % 2 == 0 )
         System.out.println("You entered an even number.");
         System.out.println("You entered an odd number.");


Enter an integer to check if it is odd or even 
You entered an odd number.

1 comment :

  1. Why you are not writing regularly? Interesting blog, please add more..............