Didart

Sign of Integer Numbers

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