Advertisement
veronikaaa86

01. Sign of Integer Numbers

Oct 6th, 2021
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 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 number = Integer.parseInt(scanner.nextLine());
  10.  
  11. printSign(number);
  12. }
  13.  
  14. public static void printSign(int num) {
  15. if (num > 0) {
  16. System.out.printf("The number %d is positive.", num);
  17. } else if (num < 0) {
  18. System.out.printf("The number %d is negative.", num);
  19. } else {
  20. System.out.println("The number 0 is zero.");
  21. }
  22. }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement