I have tried many variations with Scanner and now Buffered reader. Any help
package com.codegym.task.task05.task0507;
/*
Arithmetic mean
*/
import java.util.Scanner;
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
int count = 0;
int num = 0;
int sum = 0;
double mean = 0;
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
while (true){
String number = read.readLine();
int num= Integer.parseInt(number);
if (num == -1)
break;
else if (num != -1)
sum += num;
count++;
}
mean = sum / count;
System.out.println(mean);
}
}