Hi,
my code does work for positive numbers, however the problem arises, when I add negative numbers. The first if condition prevents numbers <= 0 to be considered, however if i delete these lines of code, the last condition isnt met anymore (for some reason I dont understand). So I managed to get into a dead end situation. Any advice?
Thanks in advance!
package de.codegym.task.task05.task0532;
import java.io.*;
/*
Aufgabe zu Algorithmen
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int maximum = Integer.MIN_VALUE;
int zaehler = 0;
int i = 0;
while(i < 6){
int zahl = Integer.parseInt(reader.readLine());
if(zahl <= 0){
break;
}
if(maximum < zahl){
maximum = zahl;
}
i++;
}
if(maximum > 0){
System.out.println(maximum);
}
}
}