while I have more stuff to get, go back in house and get another item
while condition, actions
while ( test ) { statements }
prompt for distance while distance < 0, do prompt for distance again
System.out.print("Enter the distance: "); double distance = in.nextDouble(); while ( number < 0 ) { System.out.print("Cannot have a negative distance; please re-enter: "); distance = in.nextDouble(); }
stars_printed <- 0 while stars_printed < 10, do print '*' increment stars_printed
int stars_printed; stars_printed = 0; while ( stars_printed < 10 ) { System.out.print('*'); stars_printed++; }
int stars_printed; stars_printed = 0; while ( stars_printed < 10 ); { System.out.print('*'); stars_printed++; }
int counter; counter = 1; while ( counter <= 10 ) { System.out.print(counter); counter++; }
initialize loop-control variable while not at limit, do process data update loop-control variable
read first item ("priming read") while item not sentinel process read next item
sum <- 0 count <- 0 read num while num != 9999 sum = sum + num increment count read num print sum / count
final int SENTINEL = 9999; int sum, count, num; sum = 0; count = 0; num = in.nextInt(); while ( num != SENTINEL ) { sum = sum + num; count++; num = in.nextInt(); } System.out.println((double)sum / (double)count);
// print specified number of lines of stars with width stars on // each line public static void int main(String[] args) { final int WIDTH = ??; final int LINES = ??; }