JK Week5 Random
JK Week5 Random
JK Week5 Random
Sample Run
The first die shows 3.
The second die shows 14.
The total is 17.
Sample Run
The dice sum to 28.
The dice sum to 13.
The dice sum to 39.
[Omitting 46 lines!!!]
The dice sum to 20.
Sample Run
You got snake-eyes 35 times out of 100000.
That is .035 percent of the time.
Roughly, that is 1 in 2857 times.
Note: The numbers shown above are NOT realistic. This is just to show the format desired for
your output.
Problem D: Different Dice Game
Consider the following game for two players:
The first player rolls a pair of dice of fair six-sided dice. If the two dice show different numbers,
the player's score is the larger of the two numbers. Otherwise, the player's score is the sum of the
two numbers.
At this point, the player is asked if they want to remove their lower die and re-roll one die. If
they say no, the player keeps her score and their turn is over. If they say yes, then they roll one
more die and the number showing on this die replaces the lower of the original two rolls. Then
these two dice rolls are scored accordingly. (For example, if the initial roll was a 2 and 5, if the
player doesn't roll again, she gets 5 points. If she does roll again and obtains a 4, her score is still
5. If she rolled again and obtained a 6, her score would be a 6. If she rollwed again and obtained
a 5, her score would be a 10.)
The second player goes after the first, doing the exact same steps as the first player.
When the second player finishes his turn, the game ends. The winner is the person with the
higher score. If both players have the same score, they tie.
Write a program to simulate this game between two players. Print out the winner at the end (or
the fact that the players tied.)
Sample Run
Player 1, you rolled a 4 and a 3.
Do you want to reroll(yes/no)?
yes
Your second roll was a 5.
Your final score is 5.
Sample Run
Player 1, you rolled a 5 and a 4.
Do you want to reroll(yes/no)?
yes
Your second roll was a 5.
Your final score is 10.