#include <iostream>
#include <ctime> // for time()
#include <cstdlib>
usingnamespace std;
int main ()
{
int dieOne=0;
int dieTwo=0;
int roll=0;
int point=0;
double odds=0;
double betmoney=50;
srand(time(0)); //makes time random seed
for(int game=1; game<4; game++)
{
dieOne=(rand()%6)+1;//creates dice
dieTwo=(rand()%6)+1;
roll=dieOne+dieTwo;
cout<<dieOne<<" plus "<<dieTwo<<" = "<<roll<<endl;
if(roll==7 || roll==11)//win on first roll
betmoney+50;
elseif(roll==2 || roll==3 || roll==12)//lose on first roll
betmoney-50;
elseif(roll==4 || roll==5 || roll==6 || roll==8 || roll==9 || roll==10)
{
point=roll;//point set
do
{
dieOne=(rand()%6)+1;//rolls dice again
dieTwo=(rand()%6)+1;
roll=dieOne+dieTwo;
cout<<dieOne<<" plus "<<dieTwo<<" = "<<roll<<endl;
if(roll==point)//wins if player rolls point
betmoney+50;
elseif(roll==7)//lose if player rolls 7
betmoney-50;
elseif(roll!=7 && roll!=point) //nothing otherwise
odds=0;
}while(roll!=point && roll!=7);//keep going until point or 7 is rolled
cout<<"game over- game #: "<<game<<endl;
}
}
cout<<"you have:$"<<betmoney<<endl;
cout<<"Probability to win is: "<<odds<<endl;
}