Last Updated: 09 August, 2022
On this tutorial page we are going to learn how to write a Java program to check whether the number is positive or negative.
Please understand the below points before going through the Java program implementation:
If a number is greater than zero (number > 0), then that number is a positive.
For Example: 1, 2, 3, 4.....
If a number is less than zero (number < 0) then that number is a negative.
For Example: -1, -2, -3, -4.....
If a number is equal to zero (number == 0) then that number is not a positive or negative.
For Example: 0
Let's see the Java program implementation.
Output
50 is a positve number.
-20 is a negative number.
The number is 0.
Output 1 :
Enter the number: 51
51.0 is a positve number.
Output 2 :
Enter the number: -286.76
-286.76 is a negative number.
That's all guys, hope this Java Program is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com