Advertisement
Spocoman

02. Greater Number

Aug 25th, 2024 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class GreaterNumber {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int num1 = Integer.parseInt(scanner.nextLine());
  7.         int num2 = Integer.parseInt(scanner.nextLine());
  8.  
  9.         if (num1 > num2) {
  10.             System.out.println(num1);
  11.         } else {
  12.             System.out.println(num2);
  13.         }
  14.     }
  15. }
  16.  
  17. ИЛИ:
  18.  
  19. import java.util.Scanner;
  20.  
  21. public class GreaterNumber {
  22.     public static void main(String[] args) {
  23.         Scanner scanner = new Scanner(System.in);
  24.         int num1 = Integer.parseInt(scanner.nextLine());
  25.         int num2 = Integer.parseInt(scanner.nextLine());
  26.  
  27.         System.out.println(Math.max(num1, num2));
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement