SHARE
TWEET

Sort Numbers - Java

damesova Jan 26th, 2019 580 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package _03_RevisionMoreExcercises;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class _01_SortNumbers {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int num1 = Integer.parseInt(scanner.nextLine());
  9.         int num2 = Integer.parseInt(scanner.nextLine());
  10.         int num3 = Integer.parseInt(scanner.nextLine());
  11.  
  12.         if (num1 > num2 && num1 > num3){
  13.             System.out.println(num1);
  14.             if (num2 > num3) {
  15.                 System.out.println(num2);
  16.                 System.out.println(num3);
  17.             } else {
  18.                 System.out.println(num3);
  19.                 System.out.println(num2);
  20.             }
  21.         } else if (num2 > num1 && num2 > num3) {
  22.             System.out.println(num2);
  23.             if (num1 > num3) {
  24.                 System.out.println(num1);
  25.                 System.out.println(num3);
  26.             } else {
  27.                 System.out.println(num3);
  28.                 System.out.println(num1);
  29.             }
  30.         } else if (num3 > num1 && num3 > num2) {
  31.             System.out.println(num3);
  32.             if (num1 > num2) {
  33.                 System.out.println(num1);
  34.                 System.out.println(num2);
  35.             } else {
  36.                 System.out.println(num2);
  37.                 System.out.println(num1);
  38.             }
  39.         }
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top