Showing posts with label check positive or negative. Show all posts
Showing posts with label check positive or negative. Show all posts

Thursday, 13 June 2013

program for to check that given number is positive or negative

import java.io.*;
class simple_check_possitive_or_negative
{
    public static void main(String args[])
    {
        try
        {
            int no;
            DataInputStream cin=new DataInputStream(System.in);
            System.out.println("Enter nuber to check it possitive or negative");
            no=Integer.parseInt(cin.readLine());
            if(no>0)
            {
                System.out.println(no+" is possitive");
            }
            else
            {
                System.out.println(no+" is negative");
            }
        }
        catch(Exception e)
        {
            System.out.println("Wrong data");
        }
    }
}