This is a java program to calculate a number which is Positive number or Negative number.
This is basic if else formula . 

You can go to jaca tutorial by click here: -->👉👉

Source Code:

  1. public class PositiveNegetiveDemo {
  2. public static void main(String[] args) {
  3.      try (Scanner input = new Scanner(System.in)) {
  4. int num;
  5.  
  6. System.out.print("Enter the number: ");
  7. num = input.nextInt();
  8.  
  9. if(num > 0) {
  10. System.out.println("positive.");
  11.     }
  12. else if(num < 0) {
  13. System.out.println("Negative.");
  14.    }
  15. else {
  16. System.out.println("Equals to Zero.");
  17.       }
  18. }
  19. }
  20. }

Output:

Enter the number: 5
positive.
Enter the number: -9
Negetive.
Enter the number: 0
Equals to Zero.

0 comments:

Post a Comment