Review Questions

Please tell me in your own words what the difference is between a for loop and a while loop.

A for loop is fixed in that it performs a set number of iterations until a specific requirement is met, incrementing an argument each time. A while loop can potentially be an infinite loop, it has no set number of iterations.

I want to know if the water is ready to steep my tea. Would it be preferable to use a for loop or a while loop to check the temperature of the water?

A while loop should be used as it will keep checking UNTIL the water is ready. If it were a for loop you would have to set a time and simply hope the water was ready after x minutes.

To fix Ben a gourmet Indian dinner, I know that I'll need 457 different items, 53 pans and Emeril Lagassi. Well, I know I can't afford Emeril Lagassi and I don't have 53 pans. But there are 457 items on my list. Would it be preferable to use a for loop or a while loop to check whether I have each item on my list?

As you have a fixed amount of items, use a for loop with a condition that checks and increments each time until it equals 457. This being said a while loop could stil be used here if the criteria for termination were that the loop control variable was != 457.