it fails on these points, while if I run it it shows the lowest number, also when I change the input for example and change the lowest number to 2 (instead of 4).
The program should display the smallest integer entered.
If several minimum numbers are entered, then you need to display any one of them.
package en.codegym.task.pro.task04.task0409;
import java.util.Scanner;
/*
Minimum of entered numbers
*/
public class Solution {
public static void main(String[] args) {
Scanner s = new Scanner (System.in);
int closestToZero = Integer.MAX_VALUE;
boolean x = true;
while (x)
{
if (s.hasNextInt()){
int a = s.nextInt();
if (Math.abs(a) < Math.abs(closestToZero)){
closestToZero = a;
}
}
else if (s.hasNextLine()){
String exit = s.nextLine();
x = false;
}
}
System.out.println(closestToZero);
}
}