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:

2 comments:

  1. 1xbet korean | RTP of 1.49 % | Online Betting
    Best Online Betting Sites: 1xbet.com - Best for sports & 1xbet app download esports, with odds and lines on all major Sports. Live betting, virtual football, esports, tennis and more.

    ReplyDelete
  2. Slots.lv Review - Slots.lv Casino Bonus Codes - DRMCD
    Slots.lv 김해 출장안마 Casino Welcome Bonus. The new player welcome bonus of up to 의왕 출장샵 $2000 is included. Play 군산 출장안마 all slots 영주 출장마사지 online 포천 출장샵 with this bonus.

    ReplyDelete