Many people take one look at a craps table at a casino and immediately go somewh
ID: 3635505 • Letter: M
Question
Many people take one look at a craps table at a casino and immediately go somewhere else. The layout seems so complex. From 1900 through the 1940's , craps was a very popular game. It was a tough guy's game. Soldiers, sailors, and wiseguys liked the game because dice are small, you can carry them anywhere, and because a game could last ten minutes or all night. Any number of people could play, and the dice (and money) could disappear in a moment if a mortar shell came arcing over or the police suddenly walked past.
By the 1990's, craps had nearly disappeared. The majority of gamblers perferred to play slots and video poker; less that four percent of gamblers play the dice. But an interesting trend has developed in the last few years. Gamblers are rediscovering the pleasures of this dice game.
How to play.
In a game of craps a player, the craps shooter, throws two die.
If the first throw (called the come-out roll) adds up to 2, 3, or 12, the player loses.
If the come-out roll adds up to 7 or 11, the player wins!
Otherwise, the player must continue throwing the dice until he/she matches their come-out roll (which means they win the game) or a 7 (which means they lose).
Write a program which plays a game of craps and stores the results in a text file.
Guidelines
1. Use ONLY reference parameters for this program.
2. Each die can have a value from 1 to 6. The value of a throw is the added value of the two die.
3. Your program must be able to generate a random integer between 1 and 6. To do this, you will need to perform the three steps below:
Step 1: You must include the following two header files at the beginning of the program in your library/header file directives.
#include <time.h>
#include <stdlib.h>
Step 2: The seed and srand must be initialized at the beginning of your main program as follows:
unsigned seed;
seed =time(NULL);
srand(seed);
Step 3: Use the following expression when you need to generate a random number from 1 to 6:
(rand() % 6) + 1;
# Declare all variables locally. Declare all constants globally.
# Create a function, Make_a_Bet, which handles the making of a bet. A player can bet any amount from $1 to the amount of money on hand. They cannot bet more money than they have.
# Create a function, Play_a_Game, which plays a single game and returns 1 if the player wins and 0 if the player loses.
# Create a function, Toss_Dice, which handles one throw of the dice (both calculating the contents of two random die and reporting the result). This function should be "called" from inside the Play_a_Game function.
# Create a text file and store all output in this file.
# In the main program, give the player $1000 to start. They must continue playing the game (with the player first making a bet) until either the player is broke or has obtained $2000.
use c++ please
Explanation / Answer
#include #include #include // needed for functions srand() and rand() #include // needed for function time() using namespace std; int rollDice(int diceVals[], int numberToRoll = 2); void gameCraps(int sum, int bankBalance, int wager); enum Status {CONTINUE, WON, LOST}; int main() { int sum; int diceVals[2]; int bankBalance = 1000; int wager; srand(time(0)); sum = rollDice(diceVals); coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.