Question: in this roll dice game #include #include #include #include int rollDice(){ return 1 + rand()%6; } int playGame(){ char hit; printf(ttttROLL THE DICE [ENTER] );

in this roll dice game

#include

#include

#include

#include

int rollDice(){

return 1 + rand()%6;

}

int playGame(){

char hit;

printf("\t\t\t\tROLL THE DICE [ENTER] ");

while ((getchar()) != ' ');

int point;

int total, d1, d2, roll = 1;

printf("--------------------------------------------------------------------------- ");

printf("ROLL NUM\tDICE #1\t\tDICE #2\t\tTOTAL ROLL\tPOINT MATCH ");

printf("--------------------------------------------------------------------------- ");

d1 = rollDice();

d2 = rollDice();

total = d1+d2;

printf("%d\t\t%d\t\t%d\t\t%d\t\t ", roll, d1, d2, total);

if(total==7 || total==11){

printf("Congratulations you rolled %d and WON ", total);

return 1;

}

else if(total==2 || total==3 || total==12){

printf("Sorry you rolled %d and LOSE ", total);

return 0;

}

point = total;

do{

roll++;

d1 = rollDice();

d2 = rollDice();

total = d1+d2;

printf("%d\t\t%d\t\t%d\t\t%d\t\t%d ", roll, d1, d2, total, point);

}while(total!=point && total!=7);

if(total==point){

printf("Congratulations you rolled %d and WON ", total);

return 1;

}

else if(total==7){

printf("Sorry you rolled %d and LOSE ", total);

return 0;

}

}

int main(){

srand(time(NULL));

int wons = 0, lost = 0;

char game;

do{

if(playGame()==1) wons++;

else lost++;

printf("Another Game [Y/N] ");

scanf("%c", &game);

while ((getchar()) != ' ');

printf(" ");

}while(game=='y' || game=='Y');

printf("Games Won : %d ", wons);

printf("Games Lost: %d ", lost);

return 0;

}

i just need to add this to the code

Create a betting amount on each game and carry the sum total of money left using a global variable. Possibilities: in c language Say a user starts the game with some default money and he/she can only place a bet using multiple of $5 If the user wins the game, it makes 3 times the bet If the user loses the game, it loses all the money he/she has bet You can decide if the user is able to place a bet every time it rolls the dice, or every time it plays a new game. The money won can get carried over to the next game If the bet money left is 0, the user can not place any more bets. When the user decides to finish playing, the amount won should be displayed.

in this roll dice game #include #include #include #include int rollDice(){ return1 + rand()%6; } int playGame(){ char hit; printf("\t\t\t\tROLL THE DICE [ENTER]

The following demonstrates a few executions of the program: ROLL THE DICE [ENTER] QUIT TO [9] DICERI DICE#2 TOTAL ROLL ROLL NUM POINT MATCH 8 8 2 6 Sorry, computer roll 7 and you loose at first try!!! Another Game? [y) ok Please enter only y or n Another Game? [y) y ROLL THE DICE (ENTER) QUIT TO (Q) ROLL NUM DICE#1 DICE#2 TOTAL ROLL POINT MATCH 1 8 POINT MATCH 11 Computer roll 12 and you win!!! another Game? [y] y ROLL THE DICE [ENTER] QUIT TO [9] ROLL NUM DICE11 DICE12 TOTAL ROLL 11 Congratulations you roll 11 and win at your first try!!! Another Game? [y) y ROLL THE DICE (ENTER) QUIT TO (a) ROLL NUM DICE#1 DICE#2 TOTAL ROLL 1 2 Congratulations you roll 7 and win at your first try!!! another Game? [Y] ROLL THE DICE [ENTER] QUIT TO (9) ROLL NUM TOTAL ROLL POINT MATCH DICE DICE#2 POINT MATCH 104 You chose to quit and you loose Another Game? [y) y ROLL. THE DICE CENTER] QUIT TO [a] ROLL NUM DICE#1 DICE#2 TOTAL ROLL POINT MATCH 8 2 Sorry, computer roll 6 and you loose Another Game? [y] n Thank you for playing You won 3 games and lost 3 games! POINT MATCH 5 5 11 would you like to bet? [Y] n. ROLL THE DICE [ENTER] QUIT TO (9) ROLL NUM DICE#1 DICE#2 TOTAL ROLL 3 5 Congratulations you roll 11 and win!!! Your remainig money is $50 Another Game? [y] y would you like to bet? [y] y You have $50, total number of $5 is 18 How many number of $5 would you like to bet? (1-10) Please enter only number between 1-10 You have $58, total number of $5 is 1e How many number of $5 would you like to bet? [1-10] You bet $5 ROLL THE DICE [ENTER] QUIT TO [4] ROLL NUM TOTAL ROLL DICE21 DICE#2 POINT MATCH 1 2 4 6 Sorry, computer roll 7 and you loose at first try!!! Your remainig money is $45 Another Game? [y] y Would you like to bet? [y] y You have $45, total number of $5 is 9 How many number of $5 would you like to bet? [1-9] You bet $35 ROLL THE DICE [ENTER] QUIT TO [9] ROLL NUM TOTAL ROLL DICE#1 DICE#2 POINT MATCH 1 5 3 8 computer roll 2 and you win!!! Your remainig money is $150 Another Game? [y) n Thank you for playing You won 2 games and lost 1 games! Your remainis money is $150

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!