I am writing a simple program to calculate the average of a set of numbers. You get the numbers using Scanner, so I am using while loop with .has
Scanner
while
.has
The problem is that Scanner will always expect an integer from System.in. You could break out of the loop using a sentinal value e.g. -1:
System.in
-1
if (temp == -1) { break; }