Can any help modify my code to make this work?
I think my logic in my while loop is correct but think the problem might be my variables outside of the loop?
Thanks in advance!

package com.codegym.task.task05.task0507;
/*
Arithmetic mean
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int aCount = 0;
int sum = 0;
while (true){
String number = reader.readLine();
int a = Integer.parseInt(number);
aCount++;
sum = sum + a;
if(a == -1){
break;
}
}
double avg = sum/aCount;
System.out.println(avg);
}
}