Guest User

01.Sort Numbers

a guest
May 24th, 2020
145
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class SortNumbers_01 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.        
  7.         int number1 = Integer.parseInt(scanner.nextLine());
  8.         int number2 = Integer.parseInt(scanner.nextLine());
  9.         int number3 = Integer.parseInt(scanner.nextLine());
  10.  
  11.         if (number1 > number2 && number1 >= number3 && number2 >= number3) {
  12.             System.out.printf("%d%n%d%n%d", number1, number2, number3);
  13.         }
  14.         else if (number2 > number1 && number2 >= number3 && number3 >= number1) {
  15.             System.out.printf("%d%n%d%n%d", number2, number3, number1);
  16.         }
  17.         else if (number2 > number1 && number2 >= number3 && number1 >= number3) {
  18.             System.out.printf("%d%n%d%n%d", number2, number1, number3);
  19.         }
  20.         else if (number3 > number1 && number3 >= number2 && number2 >= number1) {
  21.             System.out.printf("%d%n%d%n%d", number3, number2, number1);
  22.         }
  23.         else if (number3 > number1 && number3 >= number2 && number1 >= number2) {
  24.             System.out.printf("%d%n%d%n%d", number3, number1, number2);
  25.         }
  26.     }
  27. }
RAW Paste Data