import tio.*; // import package to read from keyboard /* Program to read numbers from the keyboard and * print out the average. * The average is calculated once the sentenel 0 * is entered. * * Author: Carsten Butz * 02-09-2002 */ class Average { public static void main (String[] args){ double input; int count = 0; double total = 0; double average; System.out.println("Please enter the numbers."); System.out.println("Use the sentinel 0 to calculate the average."); input = Console.in.readDouble(); while (input != 0) { total += input; count++; input = Console.in.readDouble(); } average = total/count; System.out.println("You entered " + count + " number(s)."); System.out.println("The average of those numbers is " + average + "."); } }