anonymous
2017-10-02 00:26:16 UTC
The game has 6 dice. Each die has numbers from 1 to 12 on it.
Each player (Bob and Tom) chooses 3 dice from the pile and rolls them. The sum of each player's 3 rolls is found.
If Bob's sum is higher than Tom's sum, then Bob wins the round. The same goes for Tom. If the sums are the same, there is a tie.
You do NOT need any kind of new data structure - no lists are needed. Just use 6 variables for the rolls, 3 for Tom and 3 for Bob.
The program displays all the rolls and the result of the playing against each other.
The program plays the game for the number of times specified by the user. It keeps track of how many rounds Bob won, how many Tom won and how many ties there were.
After all the rounds have been played, the results are shown.
Write the design for the program first - that will give you your comments!
Sample run:
How many rounds to play? 5
Bob's rolls: 10 2 2
Tom's rolls: 10 12 10
Tom won!
Bob's rolls: 7 2 4
Tom's rolls: 3 4 12
Tom won!
Bob's rolls: 7 1 11
Tom's rolls: 2 3 1
Bob won!
Bob's rolls: 12 11 3
Tom's rolls: 3 11 12
It's a tie!
Bob's rolls: 5 8 11
Tom's rolls: 1 6 11
Bob won!
Results:
5 Rounds played
Bob: 2 Tom: 2 Ties: 1