package com.codegym.task.task05.task0507;
import java.io.*;
/*
Arithmetic mean
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
double result = 0.0f;
int sum = 0;
int i = 0;
while(true)
{
String numbers = br.readLine();
int num = Integer.parseInt(numbers);
if(num == -1)
{
break;
}
if(num != 0)
{
sum += num;
i++;
}
}
if(sum == 0)
{
result = 0.0;
}
else
{
result = (double)sum/(double)i;
}
System.out.print(result);
}
}
Why I did not match the last requirement?
Resolved
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
niki4etoo
6 September 2018, 20:15
I figure it out. Thanks. It doesn't need to exclude the zero.
0
Roman
6 September 2018, 06:10solution
why?
+3