I checked my code - it does what it is supposed to do, but for some unknown reason the validation fails. I'm confused. Can someone help me/give me a hint where the problem lies?
package de.codegym.task.task05.task0532;
import java.io.*;
import static java.lang.System.exit;
/*
Aufgabe zu Algorithmen
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int new_number;
int n = Integer.parseInt(reader.readLine()); // Get count N of numbers to be checked
if (n <= 0) // Validate N - exit program without output if out of range
exit(0);
int maximum = 0; // Decalre and initialize maximum
// Read n numbers from console and compare each with maximum, if new number is greater than maximum, set maximu to new number
while(n > 0){
new_number = Integer.parseInt(reader.readLine());
if (new_number > maximum)
maximum = new_number;
n = n - 1;
}
System.out.println(maximum);
}
}