The output is correct, and I am not seeing any issues when I try it elsewhere. What am I missing? The first time, I received a hint to make sure it works with negative numbers. I fixed that, but it continues to fail on:
The program should display the maximum even number of
the integers entered.
&&
If several maximum even numbers are entered, then you
need to display any one of them
package en.codegym.task.pro.task04.task0408;
import java.util.Scanner;
/*
Maximum of entered numbers
*/
public class Solution {
public static void main(String[] args) {
//write your code here
Scanner s = new Scanner(System.in);
int ui = 0;
int max = Integer.MIN_VALUE;
while(s.hasNextInt()) {
ui = s.nextInt();
if((ui% 2) == 0){
if(ui > max)
max = ui;
}
} if((max == 0) || (ui == 0)) {
System.out.println(Integer.MIN_VALUE);
}else{
System.out.println(max);
}
}
}