Question: (1) One of the players goes first. That player announces the size of the bet, and rolls the dice. If the player rolls a
(1) One of the players goes first. That player announces the size of the bet, and rolls the dice. If the player rolls a 7 or 11, it is called a natural. The player who rolled the dice wins. 2, 3 or 12, it is called craps. The player who rolled the dice loses. If the player's first roll is any other number (4, 5, 6, 8, 9, or 10) the bet is not immediately decided. Instead, the number that the player rolled becomes the point and he continues to roll the dice until either he rolls the point a 2nd time, in which case he wins, or he rolls a 7, in which case he loses. For example, suppose a player's 1st roll is a 6.Then 6 becomes the point. He must roll again. If his next roll were a 3, he would have to roll a 3rd time. The point remains 6. He continues to roll the dice until he either gets a 6 (a win) or a 7 (a loss). (2) When a player wins, he collects the bet, and gets to keep the dice and take another turn. Then the play begins again with rule (1). (3) When a player loses, his opponent collects the money that was bet and it becomes the opponent's turn to roll the dice. The opponent starts play again with rule (1). Double ays D For this program, simulate a craps game for a total of at most 20 wagers. That is, the first player rolls the dice until he either wins or loses. That is the first wager. The winner then takes the dice, and rolls until the second wager is decided. And so on, for a total of 20 wagers. However, if one of the gamblers loses all of his money before the 20th wager, end the simulation at that point. Assume that each player starts out with a balance of $1000. Assume also that when player 1 is rolling, he always bets $100 on each wager. However, player 2 believes in luck and uses a strategy of his own creation. When he has the dice and it is his turn to decide how much to bet, he considers how much money he has. If he has at least as much money as he had when the game began, he decides his luck is good and bets $150. If he has less money than when the game began, he decides his luck is bad, and only bets $50 on that particular wager. Player 1 always rolls the dice first in this simulation. You must use a pseudo-random number generator to simulate a dice roll. Use the methods described in lectures and in Chapter 3 of the required textbook. To simulate the roll of one die, use the necessary operation once, with a maximum roll of 6. Since the game is played with two dice, to simulate one roll you will need to generate two numbers by using the necessary operations twice and then adding the two numbers together. Your program must print out a roll-by-roll description of what happens as the game is played. Wager 1 Bet is $100 : Player 1 is rolling the dice The roll is 2 That is craps! Player 1 loses. Currently, Player 1 has $900 and Player 2 has $1100. Wager 2 Bet is $150) Player 2 is rolling the dice. The roll is a 6. The roll is a 5. The roll is a 6. Player 2 rolls again. Player 2 rolls again. Player 2 wins. The point is 6. The point is 6. That is the point! Currently, Player 1 has $750 and Player 2 has $1250. Your output need not look exactly like this, but should be at least as easy to read. At a minimum, for each wager you must print which player is rolling the dice, and the amount of the bet. Then simulate rolling the dice, and print the result of each roll, until the winner is determined. At the end of each wager, print who won, and a running total of how much money each player has. Note that it's possible that a gambler could end up with a negative amount of money, if he or she does not have enough money left to pay the full amount of the final bet. That could be risky; luckily this is only a simulation! Use Of Functions, Parameters, Modularity, Design et. al. A major part of your grade on this and ALL future programming projects in this course will be determined by how well you utilize multiple functions and parameter passing appropriately and how well you design a modular and functionally cohesive program using the principles discussed in class. Large grade point penalties can be incurred for not setting up a modular, well designed program structure. Global variables must not be used or large point penalties will be applied. All of the above emphasizes good program structure, design, and very basic, fundamental software engineering principles. Start by working on a good design, structure chart, etc. Recitation meetings will also be an excellent source of help with this. Use Of Data Structures This project does not require the use of any data structures and you should not use any. The only classes you may use are the standard string class and standard iostream classes, as discussed in course lectures. The use of any other classes will result in grade point penalties.
Step by Step Solution
3.36 Rating (146 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
