Question: Sample Program Run: Beat the computer! You rolled a 2 and a 1 (total = 3) Do you want to keep those? (y or n)

Sample Program Run: Beat the computer! You rolled a 2 and a 1 (total = 3) Do you want to keep those? (y or n) n Rolling again.... You rolled a 4 and a 1 (total = 5) Do you want to keep those? (y or n) n

Sol46:

Sure! Here's a sample program run based on the input you provided:

Beat the computer! You rolled a 2 and a 1 (total = 3)

Do you want to keep those? (y or n) n

Rolling again....

You rolled a 4 and a 1 (total = 5)

Do you want to keep those? (y or n) n

Rolling again....

You rolled a 3 and a 6 (total = 9)

Do you want to keep those? (y or n) y

Computer's roll: 7

You win!

In this example, the initial roll is 2 and 1, which gives a total of 3. The player chooses to roll again, and gets a 4 and 1 for a total of 5. The player chooses to roll again, and gets a 3 and 6 for a total of 9. The player decides to keep this roll, and the computer rolls a total of 7. Since the player's total is greater than the computer's total, the player wins.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!