Advertisement
veronikaaa86

01. Sign of Integer Numbers

Oct 5th, 2022
959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. package methods;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P01SignOfIntegerNumbers {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int numInput = Integer.parseInt(scanner.nextLine());
  10.  
  11.         printNumbersSign(numInput);
  12.     }
  13.  
  14.     public static void printNumbersSign(int num) {
  15.         if (num < 0) {
  16.             System.out.printf("The number %d is negative.", num);
  17.         } else if (num > 0) {
  18.             System.out.printf("The number %d is positive.", num);
  19.         } else {
  20.             System.out.printf("The number %d is zero.", num);
  21.         }
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement