Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- int main (void)
- {
- int value,spin;
- double bet,total;
- // start of the loop.
- while (total!=0)
- {
- // asking for the number to bet on.
- printf("place your bet on a number between 0 and 36:\n");
- scanf("%d",&value);
- while (value<0 || value>36)
- {
- printf("place your bet on a number between 0 and 36:\n");
- scanf("%d",&value);
- }
- // user enters the bet
- printf("Enter a bet in dollars $:\n");
- scanf("%lf",&bet);
- srand(time(NULL));
- spin=rand()%36;
- if (bet==0.0) // if the bet is entered as 0.0 the program quits.
- {
- printf("\nThank you for playing. You leave the table with $%.2f.\n",total);
- return 0;
- }
- if (spin==value)
- {
- total +=(bet*5);
- total=fabs(total);
- printf("\nThe result of the spin is %d\n",spin);
- printf("\nyou now have $%.2f to game with.\n\n",total);
- }
- else if (value%2==0 && spin%2==0 && value!=0 && spin!=0)
- {
- total += bet;
- total=fabs(total);
- printf("\nThe result of the spin is %d\n",spin);
- printf("you now have $%.2f to game with.\n\n",total);
- }
- else if ( (value%2==1) && (spin%2==1) && (value!=0) && (spin!=0))
- {
- total+= bet;
- total=fabs(total);
- printf("\nThe result of the spin is %d\n",spin);
- printf("you now have $%.2f to game with.\n\n",total);
- }
- else
- {
- total-=bet;
- printf("\nThe result of the spin is %d\n",spin);
- printf("you now have $%.2f to game with.\n\n",total);
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment