in C++
This assignment is to use your knowledge of Chap 1-5 to write a simulation program to estimate the winning chance of the Craps game. Craps is a popular dice game played in casinos. Here is how to play: Roll two dice. Each die has 6 faces representing values 1,2,3,4,5,and 6, respectively. Check the sum of 2 dice. If the sum is 2, 3, or 12 (called craps), you lose; if the sum is 7 or 11 (called natural), you win; if the sum is another value (i.e., 4,5,6,8,9,or10) a point is established. Continue until you roll either a 7 (you lose) or the same point value (you win). Here are few cases: 1. You rolled 5 + 6 = 11 You win 2. You rolled 1 + 2 = 3 You lose 3. You rolled 4 + 4 = 8 Point is 8, then you rolled 5 + 6 = 11 (continue rolling), then rolled 6 + 2 = 8 (You win) 4. You rolled 3 + 2 = 5 Point is 5, then you rolled 2 + 5 = 7 (You lose) Let the game be played for 1000 times to estimate the winning chance. Report the chance. Note: You’ll need to use random number function, rand(). (See page 129 of your textbook for proper header files and using system time for random seed) Besides, when you roll a die, use formula, rand()%6+1, to get the random face value of a die. A day before the due date, the number of plays will be released on Blackboard, which your submission of the assignment needs to follow.
#include <iostream>
#include <cstdlib>
#include<ctime>
using namespace std ;
int main(void)
{
srand(time(0));
int point = rand() % 6 + 1;
point = point + rand() % 6 + 1;
double loss = 0 ;
double win = 0 ;
int count = 0 ;// one time game has been played
while( count < 1000 ) {
if (point == 2 || point == 3 || point == 12) {
loss++;
count++;
point = 0;
continue ;
}
else if (point == 7 || point == 11) {
win++;
count++;
point = 0 ;
}
else if (point == 4 || point == 5 || point == 6 || point == 8 || point == 9 || point == 10) {
point = (point + rand() % 6 + 1) % 12 + 1;
continue;
}
point = rand() % 6 + 1;
point = point + rand() % 6 + 1;
}
//calculate probability
double win_chance = win /1000;
cout<< " The probability to win is " << win_chance<< endl ;
return 0;
}

in C++ This assignment is to use your knowledge of Chap 1-5 to write a simulation...
This is in C++. The program needs to show the points as well.
The blue boxes show below are the output and it should look like
that. Thanks
(Game: craps) Craps is a popular dice game played in casinos. Write a program to play a variation of the game, as follows: Roll two dice. Each die has six faces representing values 1, 2, ..., and 6, respectively. Check the sum of the two dice. If the sum is 2, 3,...
Write a c++ program that simulates a million of games in craps. I am having a trouble getting to loop a million of times. I am trying to use a const for a million. This is the code so far. #include <iostream> #include <cstdlib>// contains prototypes for functions srand and rand #include <ctime>// contains prototype for function time #include <iomanip> using namespace std; int rollDice(); // rolls dice, calculates and displays sum void printstats(); int totroll = 0, games, point,...
Problem 9 A single game of craps (a dice game) consists of at most two rolls of a pair of six sided dice. The ways to win are as follows: Win-the first roll of the pair of dice sums to either 7 or 1 (you win, game over, no second roll Win the first roll of the pair of dice does NOT sum to either 7 or 1 but the sum of the second roll is equal to the sum...
Java programming Write a simulation of the Craps dice game. Craps is a dice game that revolves around rolling two six-sided dice in an attempt to roll a particular number. Wins and losses are determined by rolling the dice. This assignment gives practice for: printing, loops, variables, if-statements or switch statements, generating random numbers, methods, and classes. Craps game rules: First roll: The first roll (“come-out roll”) wins if the total is a 7 or 11. The first roll loses...
Write a Complete Java program for the following specification: One of the most popular games of chance is a dice game known as “craps,” which is played in casinos and back alleys throughout the world. The rules of the game are straightforward: A player rolls two dice. Each die has six faces. These faces contain 1, 2,3,4,5, and 6 spots. After the dice have come to rest, the sum of the spots on the two upward faces is calculated. If...
Java Craps in Java. The following are the rules for a pass bet in the game of craps. Roll two six-sided dice, and let x be their sum. If x is 7 or 11, you win. If x is 2, 3, or 12, you lose. Otherwise, repeatedly roll two the dice until their sum is either x or 7. If their sum is x, you win. If their sum is 7, you lose. Compose a modular program to estimate the...
Write a C++ game that plays Craps. Craps is a game played with a pair of dice. The shooter (the player with the dice) rolls a pair of dice and the number of spots showing on the two upward faces are added up. If the opening roll (called the ‘come out roll’) is a 7 or 11, the shooter wins the game. If the opening roll results in a 2 (snake eyes), 3 or 12 (box cars), the shooter loses,...
C++ programming language, starting out with C++. Looping Constructs Write a program to simulate the casino game "craps". It should execute N number of games so that you can compute the probability(%) of the "player" winning and the "house" winning. Probability(%) of the "player" winning = PlayerWins / N * 100. Probability(%) of the "house" winning = HouseWins / N * 100. The rules are: Player rolls two dice. When the sum is 7 or 11 on first throw, player...
This is for C++ #include <random> #include <iostream> #include <ctime> using namespace std; /* In the game of craps, a shooter rolls 2 dice and adds the dots on the upper most faces of the dice. 7 or 11 on the first roll wins, 2, 3, or 12 on the first roll loses, andthing else is call the point and the player rolls again The following program fragment uses 1-way if statements simulate the 1st roll of the dice. Replace...
C# Code: Write the code that simulates the gambling game of craps. To play the game, a player rolls a pair of dice (2 die). After the dice come to rest, the sum of the faces of the 2 die is calculated. If the sum is 7 or 11 on the first throw, the player wins and the game is over. If the sum is 2, 3, or 12 on the first throw, the player loses and the game is...