/** * Matt Kretchmar * February 3, 2006 * PrintAverage2.java * This program computes the avereage of five integers read from * the user. It uses a while loop to read in the values. */ import java.util.Scanner; class PrintAverage2 { public static void main (String [] args) { Scanner keyboard = new Scanner(System.in); double average = 0; int input; int i; //loop control variable i = 1; // loop initialization while ( i <= 5 ) // loop condition { // loop body System.out.println("Enter num" + i + ": "); input = keyboard.nextInt(); average = average + input; // loop update i++; } average = average / 5.0; System.out.println("average = "+average); } }