Advertisement
veronikaaa86

01. Sign of Integer Numbers

Feb 1st, 2023
768
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 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 num = Integer.parseInt(scanner.nextLine());
  10.  
  11.         printNumberSign(num);
  12.     }
  13.  
  14.     public static void printNumberSign(int num) {
  15.         String signWord = "";
  16.         if (num < 0) {
  17.             signWord = "negative";
  18.         } else if (num > 0) {
  19.             signWord = "positive";
  20.         } else {
  21.             signWord = "zero";
  22.         }
  23.         System.out.printf("The number %d is %s.%n", num, signWord);
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement