So, after working on this. Finally I did it. This one has a small mistake, but I really don't want to fix it, so if I still want to edit it, then I will be my guest.
Scanner input = new Scanner(System.in);
int studentNum = 0;
ArrayList<Integer> calc = new ArrayList<Integer>();
while (studentNum <= 100) {
System.out.print("Enter a number: ");
calc.add(input.nextInt());
studentNum += 1;
if (input.nextInt() == -99) {
break;
}
}
int min = Collections.min(calc);
int max = Collections.max(calc);
for (int i = 0; i < calc.size(); i++) {
int number = calc.get(i);
if (number < min)
min = number;
if (number > max)
max = number;
}
System.out.println("Max is " + max);
System.out.println("Min is " + min);
It does exactly what you want. However, there was a problem checking the output signal.
if (input.nextInt() == -99) {
break;
}
, userInput -99, min max. , , , userInput , -99. , .
, .
EDIT , .