Не проходит 2 условие, хотя все работает..
package com.javarush.task.task06.task0622;
import org.w3c.dom.ls.LSOutput;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
Числа по возрастанию
*/
public class Solution {
public static int min;
public static int max;
public static int minimum;
public static int maximum;
public static void calculation(int a, int b, int c)
{
/* min */
if (a < b && a < c) { minimum = a; } else if (b < a && b < c) {
minimum = b;
} else if (c < a && c < b) {
minimum = c;
}
/* max */
if (a > b && a > c) {
maximum = a;
} else if (b > a && b > c) {
maximum = b;
} else if (c > a && c > b) {
maximum = c;
}
/* average */
if (a > minimum && a < maximum) {
System.out.println(minimum);
System.out.println(a);
System.out.println(maximum);
}
else if (b > minimum && b < maximum)
{
System.out.println(minimum);
System.out.println(b);
System.out.println(maximum);
}
else if (c > minimum && c < maximum)
{
System.out.println(minimum);
System.out.println(c);
System.out.println(maximum);
}
}
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int n1 = Integer.parseInt(reader.readLine());
int n2 = Integer.parseInt(reader.readLine());
int n3 = Integer.parseInt(reader.readLine());
int n4 = Integer.parseInt(reader.readLine());
int n5 = Integer.parseInt(reader.readLine());
if (n1 < n2 && n1 < n3 && n1 < n4 && n1 < n5)
{
min = n1;
}
else if (n2 < n1 && n2 < n3 && n2 < n4 && n2 < n5)
{
min = n2;
}
else if (n3 < n1 && n3 < n2 && n3 < n4 && n3 < n5)
{
min = n3;
}
else if (n4 < n1 && n4 < n2 && n4 < n3 && n4 < n5)
{
min = n4;
}
else if (n5 < n1 && n5 < n2 && n5 < n3 && n5 < n4)
{
min = n5;
}
if (n1 > n2 && n1 > n3 && n1 > n4 && n1 > n5)
{
max = n1;
}
else if (n2 > n1 && n2 > n3 && n2 > n4 && n2 > n5)
{
max = n2;
}
else if (n3 > n1 && n3 > n2 && n3 > n4 && n3 > n5)
{
max = n3;
}
else if (n4 > n1 && n4 > n2 && n4 > n3 && n4 > n5)
{
max = n4;
}
else if (n5 > n1 && n5 > n2 && n5 > n3 && n5 > n4)
{
max = n5;
}
if (n1 == min) {
if (n2 == max) {
System.out.println(min);
calculation(n3,n4,n5);
System.out.println(max);
} else if (n3 == max) {
System.out.println(min);
calculation(n2,n4,n5);
System.out.println(max);
} else if (n4 == max) {
System.out.println(min);
calculation(n2,n3,n5);
System.out.println(max);
} else if (n5 == max) {
System.out.println(min);
calculation(n2,n3,n4);
System.out.println(max);
}
}
if (n2 == min) {
if (n1 == max) {
System.out.println(min);
calculation(n3,n4,n5);
System.out.println(max);
} else if (n3 == max) {
System.out.println(min);
calculation(n1,n4,n5);
System.out.println(max);
} else if (n4 == max) {
System.out.println(min);
calculation(n1,n3,n5);
System.out.println(max);
} else if (n5 == max) {
System.out.println(min);
calculation(n1,n3,n4);
System.out.println(max);
}
}
if (n3 == min) {
if (n1 == max) {
System.out.println(min);
calculation(n2,n4,n5);
System.out.println(max);
} else if (n2 == max) {
System.out.println(min);
calculation(n1,n4,n5);
System.out.println(max);
} else if (n4 == max) {
System.out.println(min);
calculation(n1,n2,n5);
System.out.println(max);
} else if (n5 == max) {
System.out.println(min);
calculation(n1,n2,n4);
System.out.println(max);
}
}
if (n4 == min) {
if (n1 == max) {
System.out.println(min);
calculation(n2,n3,n5);
System.out.println(max);
} else if (n2 == max) {
System.out.println(min);
calculation(n1,n3,n5);
System.out.println(max);
} else if (n3 == max) {
System.out.println(min);
calculation(n1,n2,n5);
System.out.println(max);
} else if (n5 == max) {
System.out.println(min);
calculation(n1,n2,n3);
System.out.println(max);
}
}
if (n5 == min) {
if (n1 == max) {
System.out.println(min);
calculation(n2,n3,n4);
System.out.println(max);
} else if (n2 == max) {
System.out.println(min);
calculation(n1,n3,n4);
System.out.println(max);
} else if (n3 == max) {
System.out.println(min);
calculation(n1,n2,n4);
System.out.println(max);
} else if (n4 == max) {
System.out.println(min);
calculation(n1,n2,n3);
System.out.println(max);
}
}
}
}