Program to display message whether the given number is positive, negative or zero.

import java.io.*;
class hello
{    public static void main(String[] edc)throws IOException
{
BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
int n;
String num;
System.out.println("Enter a number::");
num= obj.readLine();
n=Integer.parseInt(num);
if(n==0) System.out.println("Number is zero.");
else if(n>0) System.out.println("Number is positive.");
else if(n<0) System.out.println("Number is negative.");

}
}
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