revised: 10/09/98, 08/09/99, 04/18/00, 07/13/02, 05/21/03, 01/15/06, 08/26/2010, 07/05/2014, 06/23/2018

go to home page   go to next page hear noise highlighting

CHAPTER 23 — Result-controlled Loops

A third kind of loop can be built from the fundamental control statements in Java. This is the result-controlled loop. (Other names for it are free loop and general loop).

A result-controlled loop keeps looping until the computation has reached a particular goal, without knowing exactly how long that might take. It is like the instruction in a cookie recipe that says "keep stirring until the ingredients are thoroughly blended." You quit stirring only when the desired goal has been achieved.

Chapter Topics:


QUESTION 1:

You put $1000 in the bank at 5% annual compound interest. How much will you have at the end of one year?


go to home page   go to next page