Showing posts with label even odd. Show all posts
Showing posts with label even odd. Show all posts

Sunday, 8 September 2013

Java Program to find whether entered number is even or odd

import java.util.Scanner;

class Evenodd
{
    public static void main(String ar[])
    {
        int a,b;
        System.out.println("Enter the Positive number to check, that is even or             
        odd.");
        
        Scanner in = new Scanner(System.in);
        a = in.nextInt();
        
        b=a%2;
        
        if(b==1)
        {
            System.out.println("Odd");
        }
        else
        {
            System.out.println("Even");
        }
    }    
}


Output: