The following code demonstrates how to Check Whether a Number is Positive in Java.
Basically, this program allows a user to enter a number. It checks whether the entered number is positive, negative, or zero.
import java.util.Scanner;
public class Exercise1A
{
public static void main(String[] args) {
int my_num;
System.out.println("Enter a Number: ");
Scanner scn=new Scanner(System.in);
my_num=scn.nextInt();
if(my_num>0)
System.out.println(my_num+" is positive!");
else
if(my_num<0)
System.out.println(my_num+" is negative!");
else
System.out.println(my_num+" is zero!");
}
}
Output

Further Reading
- Angular
- ASP.NET
- C
- C#
- C++
- CSS
- Dot Net Framework
- HTML
- IoT
- Java
- JavaScript
- Kotlin
- PHP
- Power Bi
- Python
- Scratch 3.0
- TypeScript
- VB.NET
