UNB/ CS/ David Bremner/ teaching/ java/ Average.java
public class Average
{  public static void main(String[] args)
   {  ConsoleReader console = new ConsoleReader(System.in);
      System.out.println("Enter data:");
      
      double sum = 0;
      int count = 0;
      
      // compute sum of all input values
      
      boolean done = false;
      while (!done)
      {  String inputLine = console.readLine();
         if (inputLine == null)
            done = true;
         else
         {  double x = Double.parseDouble(inputLine);
            sum = sum + x;
            count++;
         }
      }
      
      // compute average

      if (count == 0) 
         System.out.println("No data");
      else 
         System.out.println("Average = " + sum / count);
   }
}