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. * (Note that the program contains a logical error.) * * Author: Carsten Butz * 02-09-2002 */ class Average2 { 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."); do{ input = Console.in.readDouble(); total += input; count++; } while (input !=0); if(count == 0) System.out.println("No numbers were entered!"); else { average = total/count; System.out.println("You entered " + count + " numbers."); System.out.println("The average of those numbers is " + average + "."); } } }