Please whats wrong with this code. It's passing all the conditions except the last one :(
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 reader = new BufferedReader(new InputStreamReader(System.in));
int sum = 1;
int count = -1;
while (true) {
String num = reader.readLine();
int a = Integer.parseInt(num);
count = count + help(a);
sum = sum + a;
if (a == -1)
break;
}
double c = count/1.0;
double mean = 0.0;
if (sum == 0){
mean = 0.0;
}
else if (count == 1){
mean = 1.0;
}
else if (sum > 1|| sum<0){
mean = sum/c;
}
System.out.println(mean);
}
private static int help(int x) {
if (x > 0){
return 1;}
else if (x<0){
return 1;
}
else return 0;
}
}