Writer a program to input a number from user check and display whether the number is
positive or negative or zero
Answers
Answered by
2
import java.util.Scanner;
public class PNZ
{
public static void main (String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Please enter a number : ");
double num = sc.nextDouble();
if (num > 0)
{
System.out.println("Positive");
}
else if (num < 0)
{
System.out.println("Negative");
}
else
{
System.out.println("Zero");
}
sc.close();
}
}
Similar questions