Everytthing works fine but the "-100, 0, 100, -1" condition, and I don't really understand why or how to fix it, thanks!
package com.codegym.task.task05.task0507;
/*
Arithmetic mean
*/
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int a = 1;
int counter = 0;
double b = 0.0;
while (a != 0){
a = sc.nextInt();
if (a == -1)
break;
counter++;
b = b+a;
}
double mean = b/ counter;
System.out.println(mean);
}
}