I tired with different numbers and it seems to return the maximum number in all cases. No idea how to solve it
package pl.codegym.task.task05.task0532;
import java.io.*;
import java.util.*;
/*
Zadanie z algorytmami
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int maksimum = 0 ;
int m;
while(true){
String s = reader.readLine();
if(s!=null) {
m = Integer.parseInt(s);
if(maksimum<=m||maksimum==0) {
maksimum = m;
}
}
else {
break;
}
}
System.out.println(maksimum);
}
}