`num`

is equal to `0`

.You then try to divide the

`sum`

by `num`

, which will (obviously) give you a "divide by zero" error.You need a separate variable to keep track of how many numbers the user has entered.

You'll also need to convert at least one side of the division to a floating-point number; otherwise, Java will perform an "integer division", truncating the result to fit in an integer. For example, using integers, the average of

`1`

and `2`

would be `1`

, which is clearly not correct.