public static void main(String[] args) throws Exception { BufferedReader reader=new BufferedReader(new InputStreamReader(System.in)); int inputValue; double average=0; boolean end=false; while(!end){ inputValue=Integer.parseInt(reader.readLine()); average=(average+inputValue)/2; if(inputValue==-1){ end=true; } System.out.println(average); } }