You don't really have a problem with Scanner; you have misunderstood how a loop works. What you are doing is
testing nextInt() to see whether it is 0, and the reading the next result of
nextInt(). You might not have entered anything to read, so your program will wait for the next input. You will have similar problems with line 20.
You only need to test the value once in the loop, and you need to use that value. So you need to read
nextInt(), assign it to something, and then text whether you have got 0. You will need some strange‑looking syntax which you would never guess in a month of Sundays. This is what I would do. Note you need an additional pair of
() because you want the
= operator executed before the
!=.
Don't call a variable
temp because many people will misinterpret that as meaning “temporary”. Your latest code won't compile because you haven't declared and initialised
temp.
You can (maybe should) use
var instead of
int in lines 3‑4, but
var won't work in line 2. The reason for multiplying by
1.0 in line 10 is to convert the value to a
double because the rounding in integer arithmetic might be too severe and give you an average of 0. See what happens if you enter 0 for the first value and you have no input at all
Forget about
nextLine() calls,
etc.; you don't need them here. That call will probably remove the first number you enter.
Don't use two Scanners to read System.in. You only ever need one. You will have to think again about different months.