Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Exercise 6.22 on page 257 of the textbook. Include a void function, called GetRoll, that takes one integer parameter and generates a random roll

Programming Exercise 6.22 on page 257 of the textbook. Include a void function, called GetRoll, that takes one integer parameter and generates a random roll of a die. Include a value-returning function, called CalcSum, that takes two integer parameters and returns the sum of the two given rolls. Include a void function, called PrintRoll, that takes three integer parameters and outputs the message describing the two rolled values and their sum, as shown in the textbook. Roll two dice. Each die has six faces representing values 1, 2, , and 6, respectively. Check the sum of the two dice. If the sum is 2, 3, or 12 (called craps), you lose; if the sum is 7 or 11 (called natural), you win; if the sum is another value (i.e., 4, 5, 6, 8, 9, or 10), a point is established. Continue until you roll either a 7 (you lose) or the same point value (you win). Your program acts as a single player.

Here are some sample runs: You rolled 5 + 6 = 11 You win You rolled 1 + 2 = 3 You lose You rolled 4 + 4 = 8 point is 8 You rolled 6 + 2 = 8 You win You rolled 3 + 2 = 5 point is 5 You rolled 2 + 5 = 7 You lose

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions