Guest User

Untitled

a guest
Feb 14th, 2020
76
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class MoreExercise {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int number1 = Integer.parseInt(scanner.nextLine());
  7. int number2 = Integer.parseInt(scanner.nextLine());
  8. int number3 = Integer.parseInt(scanner.nextLine());
  9. int maxNumber = Math.max(number1, Math.max(number2, number3));
  10. int minNumber = Math.min(number1, Math.min(number2, number3));
  11. int midNumber = 0;
  12. if (maxNumber == number1 && minNumber == number2) {
  13. midNumber = number3;
  14. } else if (maxNumber == number1 && minNumber == number3) {
  15. midNumber = number2;
  16. } else if (maxNumber == number2 && minNumber == number1) {
  17. midNumber = number3;
  18. } else if (maxNumber == number2 && minNumber == number3) {
  19. midNumber = number1;
  20. } else if (maxNumber == number3 && minNumber == number1) {
  21. midNumber = number2;
  22. } else if (maxNumber == number3 && minNumber == number2) {
  23. midNumber = number1;
  24. }
  25. System.out.println(maxNumber);
  26. System.out.println(midNumber);
  27. System.out.println(minNumber);
  28. }
  29. }
RAW Paste Data