Web site counters - Chapter 6: Controlling Program Flow with Loops 125

Chapter 6: Controlling Program Flow with Loops 125 Figure 6-1: Play until you drop. In Figure 6-1, the user makes four guesses. Each time around, the computer checks to see whether the guess is correct. An incorrect guess generates a request to try again. For a correct guess, the user gets a rousing You win, along with a tally of the number of guesses he or she made. The computer repeats several statements over and over again, checking each time through to see whether the user s guess is the same as a certain randomly generated number. Each time the user makes a guess, the computer adds 1 to its tally of guesses. When the user makes the correct guess, the computer displays that tally. The flow of action is illustrated in Figure 6-2. Welcome to the Guessing Game Enter an int from 1 to 10: Get inputNumber from the user Add 1 to numGuesses Compare inputNumber and randomNumber They’re different Try again… They’re the same Enter an int from 1 to 10: Get inputNumber from the user Add 1 to numGuesses Figure 6-2: Around and around you go. You win after numGuesses
File Transfer Protocol comes together with anonymous ftp access with every FTP Web Hosting account we offer today. Enjoy burs table ftp transfers together with fast FTP connection.

Leave a Reply