The code apparently satisfies all conditions except "3. After entering -1, the program must correctly terminate."
Though with "Run (without verification)", I get the required results for all the combinations listed..
package com.codegym.task.task05.task0507;
import java.io.*;
/*
Arithmetic mean
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s = reader.readLine();
int ss = Integer.parseInt(s);
int sw = 0;
int count = 0;
Double mean = 0.0;
boolean isExit = false;
while (!isExit)
{
sw = sw + ss;
s = reader.readLine();
ss = Integer.parseInt(s);
count++;
isExit = s.equals("-1");
}
mean = (double)sw/count;
System.out.println(mean);
}
}