import java.io.*; class Average6e { // A program that calculates the average of a series of // integers. It prompts for each one. A non-numeric value // indicates the end of the series. public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader (new InputStreamReader(System.in)); int sum=0,count=1,n,fraction; while(true) { System.out.print("Enter number "+count); System.out.print(" or a non-number to finish: "); try { n=Integer.parseInt(in.readLine()); sum+=n; count++; } catch(NumberFormatException e) { break; } } try { System.out.print("Average is: "+sum/(count-1)+"."); fraction = (sum*100/(count-1))%100; if(fraction<10) System.out.println("0"+fraction); else System.out.println(fraction); } catch(ArithmeticException e) { System.out.println("No data entered"); } } }