SHARE
TWEET

SortNumbers

Helena12 Jan 23rd, 2019 297 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class SortNumbers {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.      double n1 = Double.parseDouble(scanner.nextLine());
  8.      double n2 = Double.parseDouble(scanner.nextLine());
  9.      double n3 = Double.parseDouble(scanner.nextLine());
  10.  
  11.      if (n1 <= n2 && n2 <= n3) {
  12.          System.out.printf("%.0f\n%.0f\n%.0f", n3, n2, n1);
  13.      } else if (n2 <= n3 && n3 <= n1) {
  14.          System.out.printf("%.0f\n%.0f\n%.0f", n1, n3, n2);
  15.      } else if (n3 <= n1 && n1 <= n2) {
  16.          System.out.printf("%.0f\n%.0f\n%.0f", n2, n1, n3);
  17.      } else if (n1 <= n3 && n3 <= n2) {
  18.          System.out.printf("%.0f\n%.0f\n%.0f", n2, n3, n1);
  19.      } else if (n2 <= n1 && n1 <= n3) {
  20.          System.out.printf("%.0f\n%.0f\n%.0f", n3, n1, n2);
  21.      } else if (n3 <= n2 && n2 <= n1) {
  22.          System.out.printf("%.0f\n%.0f\n%.0f", n1, n2, n3);
  23.      }
  24.  
  25.     }
  26. }
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