White a program in Java to input an
integer, test, and print it the number
is PositiVE
NEGATIVE OR ZERO
Answers
Answer:
20203020103
2343.
wear
2
a
4
3
we
4
Explanation:
2j2jj2kmem
Answer:
Explanation:
This is a Java Program to Check if a Given Integer is Positive or Negative.
Enter any integer number as an input. Now we check whether the given number is greater than zero or not. If the given number is greater than zero than it is positve. If it is less than zero than it is negative and if it is zero than it is neither poistive nor negative.
Here is the source code of the Java Program to Check if a Given Integer is Positive or Negative. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
import java.util.Scanner;
public class Postive_Negative
{
public static void main(String[] args)
{
int n;
Scanner s = new Scanner(System.in);
System.out.print("Enter the number you want to check:");
n = s.nextInt();
if(n > 0)
{
System.out.println("The given number "+n+" is Positive");
}
else if(n < 0)
{
System.out.println("The given number "+n+" is Negative");
}
else
{
System.out.println("The given number "+n+" is neither Positive nor Negative ");
}
}
}
Output:
$ javac Postive_Negative.java
$ java Postive_Negative
Enter the number you want to check:6
The given number 6 is Positive