Hello,
I don't understand what's wrong here. If I initialize int n = 0 then it's not taking the first input into account.
But if I initialize it with Integer.parseInt(lecteur.readLine()) my code crashes at l.17 with the error
java.lang.NumberFormatException: For input string: ""
as if it couldn't parse correctly.
package fr.codegym.task.task05.task0532;
import java.io.*;
/*
Mission sur les algorithmes
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader lecteur = new BufferedReader(new InputStreamReader(System.in));
int maximum = 0 ;
int n = Integer.parseInt(lecteur.readLine());
int inputNumber = 0;
while(!lecteur.readLine().equals("")) {
inputNumber = Integer.parseInt(lecteur.readLine());
if ( inputNumber > 0 && inputNumber > n) {
n = inputNumber;
}
}
if(n>0) {
maximum = n;
System.out.println(maximum);
}
}
}