Monday, 28 September 2015

Java Program to verify positive (or) negative number

import java.io.*;
public class Demo {

public static void main(String[] args) throws IOException
{
// TODO Auto-generated method stub
System.out.println("Enter a number");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
/*char ch = (char)br.read();
System.out.println("The value of Ch is " +ch);*/
long i = Long.parseLong(br.readLine());
//System.out.println("The value of i is "+i);
if(i>0)
System.out.println("The value is +Ve");
else
System.out.println("The value is -Ve");
}
}

Out put:-
Enter a number
20
The value is +Ve

No comments:

Post a Comment