Program which reads a number and displays suitable message including whether the given output is number odd or even.

import java.io.*;
class hello
{ public static void main(String[] asd)throws IOException
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
int n;
String num;
loop: System.out.println("Enter the number::");
num=in.readLine();
n=Integer.parseInt(num);
if(n==0 || n==1)
{
System.out.println("ENter another number, must be greater then or equal to 2::");
continue loop;
}
if(n%2==0)
{
System.out.println("Number is EVEN.");
}
else
{
System.out.println("Number is ODD");
}
}
    }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s