Monday 9 June 2014

Program to check whether the entered number is negative, positive or zero

// Program to check whether the entered number is negative, positive or zero
import javax.swing.*;
public class number 
{
public static void main(String[] args) 
{
int n;
n=Integer.parseInt(JOptionPane.showInputDialog("enter the number"));
if(n<0)
System.out.println("number is negative");
else if(n==0)
System.out.println("number is zero");
else
System.out.println("number is positive ");

}

}
output:
enter the number -9
number is negative

No comments:

Post a Comment

SAY HELLO!!