I'm really stuck on this one. I'have tried many different solutions without any luck... Please help me on this one my fellow CodeGymnasts
package com.codegym.task.task05.task0507;
/*
Arithmetic mean
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input = br.readLine();
int numbers = Integer.parseInt(input);
int sum = 0;
int counter = 0;
double mean = 0.0;
// test stoppIT
boolean stoppIT = false;
while(!stoppIT){
if (input.equals("-1")){
break;
}
sum = sum + numbers;
input = br.readLine();
counter++;
stoppIT = input.equals("-1");
}
if (mean <= 0.0){
System.out.println(mean);
}else{
mean = sum/counter;
System.out.println(mean);
}
}
}