Requirements 1 Create a function that simulates a throw of t
Solution
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;
int dice1;
int dice2;
int sum_of_dice;
int point;
int number_of_wins;
int number_of_lose;
double probability_of_winning;
double probability_of_losing;
int number_of_times_played;
int main()
{
srand(time(0));
do
{
dice1 = rand() % 6 + 1;
dice2 = rand() % 6 + 1;
sum_of_dice = dice1 + dice2;
if (sum_of_dice == 7 || sum_of_dice == 11)
{
cout << \"Congratulations you have won!\" << endl;
}
else if (sum_of_dice == 2 || sum_of_dice == 3 || sum_of_dice == 12)
{
cout << \"Better luck next time the house has one!\" << endl;
}
else (sum_of_dice == 4 || sum_of_dice == 5 || sum_of_dice == 6 || sum_of_dice == 8 || sum_of_dice == 9 || sum_of_dice == 10);
{
do {
dice1 = rand() % 6 + 1;
dice2 = rand() % 6 + 1;
int sum2 = dice1 + dice2;
if( sum2 == sum_of_dice )
{
cout << \"Congratulations you have won!\" << endl;
break;
} else if( sum2 == 7 )
{
cout << \"Better luck next time the house has one!\" << endl;
break;
}
} while(true);
}
} while (++number_of_times_played != 1000000);
number_of_wins = number_of_times_played - number_of_lose;
number_of_lose = number_of_times_played - number_of_wins; // It is now telling me that I have never lost.
probability_of_winning = number_of_wins / 10000;
probability_of_losing = number_of_lose / 10000;
cout << \"Out of 1 million games you won: \" << number_of_wins << endl;
cout << \"Out of 1 million games you lose: \" << number_of_lose << endl;
cout << \"The probability for the Player to win is: \" << probability_of_winning << setw(2) << \"%\" << endl;
cout << \"the probability for House to win is: \" << probability_of_losing << setw(2) << \"%\" << endl;
return 0;
}//End Code!


