Advertisement
CoineTre

JF-LabMethods01.Sign of Integer

Feb 5th, 2021
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Lab1SignInt {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int number = Integer.parseInt(scanner.nextLine());
  7.         printSign(number);
  8.     }
  9.  
  10.     private static void printSign(int input) {
  11.         if (input < 0){
  12.             System.out.printf("The number %d is negative.",input);
  13.         }else if (input >0){
  14.             System.out.printf("The number %d is positive.",input);
  15.         }else{
  16.             System.out.printf("The number %d is zero.", input);
  17.         }
  18.     }
  19. }
  20.  
  21. /*Create a method that prints the sign of an integer number.*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement