95%(221)210 out of 221 people found this document helpful
This preview shows page 44 - 51 out of 53 pages.
2.Your downloadable files for Chapter 5 include a file named DEBUG05-04.jpg that contains a flowchart with syntax and/or logical errors. Examine the flowchart and then find and correct all the bugs.
Programming Logic and Design, 8eSolutions 5-45
Programming Logic and Design, 8eSolutions 5-46Game Zone1.In Chapter 2, you learned that in many programming languages you can generate a random number between 1 and a limiting value named LIMITby using a statement similar to randomNumber = random(LIMIT). In Chapter 4, you created the logic for a guessing game in which the application generates a random number and the player tries to guess it. Now, create the guessing game itself. After each guess, display a message indicating whether the player’s guess was correct, too high, or too low. When the player eventually guesses the correct number, display a count of the number of guesses that were required.
Programming Logic and Design, 8eSolutions 5-47Pseudocode:startDeclarationsnum myRandomNumbernum guessnum countnum LIMITstring PROMPT = “Enter a number between 1 and ”string CORRECT = “You guessed correctly!”string HIGH = “You guessed too high!”string LOW = “You guessed too low!”housekeeping()while guess not equal to myRandomNumberdetailLoop()endwhilefinishUp()stophousekeeping()myRandomNumber = random(LIMIT)output PROMPT, LIMIT input guess
2.Create the logic for a game that simulates rolling two dice by generating two numbersbetween 1 and 6 inclusive. The player chooses a number between 2 and 12 (the
Programming Logic and Design, 8eSolutions 5-49Pseudocode:startDeclarationsnum dice1num dice2