Any Ideas where my fault lies?
For some reason the double returns always a "...0" instead of the right value.
To make testing easier i put the println Statements in.
Thank you for every help.
package de.codegym.task.task05.task0507;
/*
Arithmetisches Mittel
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int b =0;
int c = 0;
while (true) {
String a1 = reader.readLine();
int a = Integer.parseInt(a1);
if (a == -1) {
System.out.println(arithmetischesMittelBerechnen(b,c));
break;
}
else if (a!=-1){
b=b+a;
c++;}
}
}
public static int arithmetischesMittelBerechnen(int b, int c){
return b/c;
}
}