Advertisement
kocev

BiggerNumber

Feb 19th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BiggerNumber {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int a;
  7.         int b;
  8.         System.out.println("Enter first number:");
  9.         String inputA = scanner.nextLine();
  10.         while (!inputA.matches("\\d+")) {
  11.             System.out.println("Wrong input. Try again!");
  12.             inputA = scanner.nextLine();
  13.         }
  14.         a = Integer.parseInt(inputA);
  15.  
  16.         System.out.println("Enter second number:");
  17.         String inputB = scanner.nextLine();
  18.         while (!inputB.matches("\\d+")) {
  19.             System.out.println("Wrong input. Try again!");
  20.             inputB = scanner.nextLine();
  21.         }
  22.         b = Integer.parseInt(inputB);
  23.  
  24.         System.out.println(a != b ? a > b ? "The bigger number is " + a : "The bigger number is " + b : "Both numbers are equal");
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement