it works correctly
package com.codegym.task.task06.task0622;
import javax.swing.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
Ascending numbers
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//write your code here
int a = Integer.parseInt(reader.readLine());
int maxN = Integer.MIN_VALUE;
int first=0;
int second;
int third = 0;
int forth=0;
int fifth=0;
first = a;
int b = Integer.parseInt(reader.readLine());
if (b > first) {
first = a;
second = b;
} else {
first = b;
second = a;
}
int c = Integer.parseInt(reader.readLine());
if (c > second) {
third = c;
} else if (c < first) {
third = second;
second = first;
first = c;
} else if (c > first && c < second) {
first = first;
third = second;
second = c;
}
int d = Integer.parseInt(reader.readLine());
if (d > third)
forth = d;
if (d < first) {
forth = third;
third = second;
second = first;
first = d;
} else if (d > first && d < second) {
first = first;
forth = third;
third = second;
second = d;
} else if (d > second && d < third) {
forth = third;
third = d;
}
int e = Integer.parseInt(reader.readLine());
if (e > forth)
fifth = e;
else if (e < first) {
fifth = forth;
forth = third;
third = second;
second = fifth;
first = e;
} else if (e > first && e < second) {
fifth = forth;
forth = third;
third = second;
second = e;
}else if (e>second&&e<third){
fifth=forth;
forth=third;
third=e;
}else if (e>third&&e<forth){
fifth=forth;
forth=e;
}
System.out.println(first);
System.out.println(second);
System.out.println(third);
System.out.println(forth);
System.out.println(fifth);
}
}