Hi!
I'm not sure what's wrong with this code since it seems to work.
If I enter a number higher than 0 it loops through that many times and assigns the value to maximum. If the number is higher the second loop it assigns the variable maximum to the new higher value. Then it prints the highest number. But if the number is 0 or less, nothing displays, which the last requirement asks for. But I can't get past requirement 5...
package com.codegym.task.task05.task0532;
import java.io.*;
/*
Task about algorithms
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int maximum = 0;
int n = Integer.parseInt(reader.readLine());
if(n > 0) {
for (int i = 0; i < n; i++) {
int number = Integer.parseInt(reader.readLine());
if (number > maximum) {
maximum = number;
}
}
System.out.println(maximum);
}
}
}