Craps is a popular dice game played in casinos Write a progr

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, 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, or 10), a point is established. Continue to roll the dice until either a 7 or the same point value is rolled. If 7 is rolled, you lose. Otherwise, you win. Your program acts as a single player. Here are some sample runs. You rolled 5 + 6 = 11 You win You rolled 1 + 2 You lose You rolled 4 + 4 = 8 point is 8 You rolled 6 + 2 = 8 You win You rolled 3 + 2 = 5 point is 5 You rolled 2 + 5 = 7 You lose

Solution

#include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;

int main()
{
int d1, d2 = 0;
int rd;
char rep = \'y\';


while (rep == \'y\' || rep == \'Y\')
{   
d1 = rand() % 6 + 1;
d2 = rand() % 6 + 1;
rd = d1 + d2;

cout << \"Your rolled \" << rd;
if (rd == 7 || rd == 11)
{
cout << \"!!!!! Winner !!!!!\" << endl ;
}

else if (rd == 2 || rd == 3 || rd == 12)
{
cout << \" !!!!!You lose!!!!!\" << endl;
}

else if (rd == 4 || rd == 5 ||rd == 6 ||rd == 8 || rd == 9 || rd == 10)
{   
d1 = rand() % 6 + 1;
d2 = rand() % 6 + 1;
int s2 = d1 + d2;

if( s2 == rd )
{
cout << \". Winner !\" << endl;
break;
}
else if( s2 == 7 )
{
cout << \". You Lose!\" << endl;
break;
}
}
cout <<\"Another game? Y(es) or N(o)\" << endl;
cin >> rep;

while (rep == \'n\' || rep == \'N\')
{
cout << \"Thank you for playing!\"<< endl;
}
return 0;
}
}

 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
 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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site