The code compiles just fine for me in IntelliJ IDEA, and also runs fine.
so I would assume it's a BlueJ bug.
Here is an example input and output after running it (pressing enter
after each input line)
(which means by the way your code works correctly, 4 is the average of
Which version of BlueJ are you using? I assume restart to BlueJ or even
your machine didn't work?