Create the logic for a game that simulates rolling two dice by generating two numbers between 1 and 6 inclusive The player chooses a number between 2

Create the logic for a game that simulates rolling

This preview shows page 35 - 40 out of 40 pages.

string HIGH = “You guessed too high!” string LOW = “You guessed too low!” housekeeping() while guess not equal to myRandomNumber detailLoop() endwhile finishUp() stop housekeeping() 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, 9e Solutions 5-37 Pseudocode: start Declarations num dice1 num dice2
3.Create the logic for the dice game Pig, in which a player can compete with the computer. The object of the game is to be the first to score 100 points. The user and
Programming Logic and Design, 9e Solutions 5-39 When the computer does not roll a 1 and can choose whether to roll again, generate a random value of 1 or 2. The computer will then decide to continue when the value is 1 and decide to quit and pass the turn to the player when the value is not 1. Answer : A sample solution is as follows: Pseudocode: start Declarations num dice1 num dice2 num userCount num computerCount num userTurn num LIMIT = 2 num WIN_NUM =100 housekeeping() while computerCount < WIN_NUM AND userCount < WIN_NUM detailLoop() endwhile stop housekeeping() output ”The first to 100 wins the game of Pig” userCount = 0 computerCount = 0 userTurn = 1 return detailLoop() if userTurn = 1 then output “User’s turn to roll the dice”

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture