Going Around in Circles (Or, Using Loops)
In This Chapter
The thrill of while loops
The rapture of infinite loops
The splendor of do loops
The joy of validating input
The wonder of for loops
The ecstasy of nested loops
So far, all the programs in this book have started, run quickly through their main method, and then ended. If Dorothy from The Wizard of Oz were using these programs, she'd probably say, “My, programs come and go quickly around here!”
In this chapter, you find out how to write programs that don't come and go so quickly. They hang around by using loops, which let them execute the same statements more than once.
Loops are the key to writing one of the most common types of programs: programs that get input from the user, do something with it, get more input from the user and do something with that, and keep going this way until the user has had enough.
Put another ...