how can I check if a number is negative or positive in java?
Answers
Answer:
Here are some ways to identify:-
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.
Here are some steps:-
1) public class Postive_Negative.
2) int n;
3) Scanner s = new Scanner(System.
4) System. out. print("Enter the number you want to check:");
5) n = s. nextInt();
6) if(n > 0)
7) System. out. println("The given number "+n+" is Positive");
8) else if(n < 0)
Thankyou....