Hey I'm trying to work out the minimum and maximum value from user input while disregarding the loop terminated value, which is -1. I understand how to do everything except how to disregard -1 when calculating minimum value for the input. Here's the code I've got so far:
int value = 0;
int max = value;
int min = max;
Scanner scan = new Scanner(System.in);
while (value != -1) {
System.out.print("Value: ");
value = scan.nextInt();
if (min > value) {
min = value; }
if (max < value) {
max = value; }
}
System.out.println("Min = " + min);
System.out.println("Min = " + min);
How can I calculate the minimum value while disregarding -1?
Thanks.