I don't know why I can't pass the last condition and "must work with any input" is not a helpful clue. I mean, it pretty blatantly must not work with ANY input. for example putting in words would break it. Unless that's what we're supposed to be catching.
package com.codegym.task.task05.task0507;
/*
Arithmetic mean
*/
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
double sum = 0;
double numberCount = 0;
double a;
Scanner sc = new Scanner(System.in);
while (true){
a = Double.parseDouble(String.valueOf(sc.nextDouble()));
if((a == -1) && (sum == 0)){
System.out.println(sum);
break;
} else if (a == -1){
double mean = sum / numberCount;
System.out.println(mean);
break;
} else if (a != 0){
sum += a;
numberCount ++;
}
}
//write your code here
}
}