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

• 40
• 92% (12) 11 out of 12 people found this document helpful

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”
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://www.coursehero.com/file/p2u70ric/", "fetch_time": 1627819965000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2021-31/segments/1627046154175.76/warc/CC-MAIN-20210801092716-20210801122716-00076.warc.gz", "warc_record_offset": 729896510, "warc_record_length": 147539, "token_count": 429, "char_count": 1741, "score": 3.5625, "int_score": 4, "crawl": "CC-MAIN-2021-31", "snapshot_type": "latest", "language": "en", "language_score": 0.8396071195602417, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00011-of-00064.parquet"}