Question: a. Create the logic for a dice game. The application randomly throws five dice for the computer and five dice for the player. As each
a. Create the logic for a dice game. The application randomly “throws” five dice for the computer and five dice for the player. As each random throw, store it in an array. The application displays all the values, which can be from 1 to 6 inclusive for each die. Decide the winner based on the following hierarchy of die values. Any higher combination beats a lower one; for example, five of a kind beats four of a kind.
- Five of a kind
- Four of a kind
- Three of a kind
- A pair
For this game, the numeric dice values do not count. For example, if both players have three of a kind, it’s a tie, no matter what the values of the three dice are. Additionally, the game does not recognize a full house (three of a kind plus two of a kind). Figure 6-20 shows how the game might be played in a command-line environment.

b. Improve the dice game so that when both players have the same combination of dice, the higher value wins. For example, two 6s beats two 5s.
Command Prompt Computer rolled: 5 2 6 4 2 You rolled: 1 1 1 2 3 Computer has 2 of a kind You have 3 of a kind You win Figure 6-20 Typical execution of the dice game
Step by Step Solution
3.44 Rating (163 Votes )
There are 3 Steps involved in it
a Pseudocode start Declarations num x num y num playerMatch num computerMatch num playerLargest num computerLargest num LIMIT 6 num SIZE 5 num playerDiceSIZE 0 num computerDiceSIZE 0 num playerValuesL... View full answer
Get step-by-step solutions from verified subject matter experts
