Question
The game of Craps is a game in which players make wagers on the outcome of the roll of a pair of dice. Each dice
The game of Craps is a game in which players make wagers on the outcome of the roll of a pair of dice. Each dice is has six sides (labeled 1, 2, 3, 4, 5, 6.) Consider the following possible outcomes from the roll of the dice:
Name | Outcome |
Snake eyes | The sum of the faces of both dice is 2. |
Ace Deuce | The sum of the faces of both dice is 3. |
Seven Out | The sum of the faces of both dice is 7. |
Yo | The sum of the faces of both dice is 11. |
Boxcars | The sum of the faces of both dice is 12. |
In the game itself, seven out and yo would be considered winning rolls, whereas the other three outcomes would be considered craps.
For your program, you will write a program simulating rolls of the dice. Your program should ask the user how many times the simulation should occur. For instance if the user enters 10000, your program should execute 10000 rolls of a pair of dice. Your program should output the number of times each of the five outcomes above occurred (as well as the percentage of each respect to the total number of rolls.) Assume the dice are not loaded, or trick dice.
Hint #1: to obtain a random number between 1 and 6, you can use (1 + rand() % 6), ensuring that srand() is seeded with the current time.
Hint #2: the following code can be used to generate two unique random numbers:
#include
#include
#include
#include
using namespace std;
int main()
{
time_t seconds; time(&seconds); srand((unsigned int)seconds); int roll1 = 1 + rand() % 6; cout << roll1 << endl; int roll2 = 1 + rand() % 6; cout << roll2;
int stop; cin >> stop; return 0;
}
Input validation: do not accept numbers of rolls less than one. Save
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started