Guest User

Untitled

a guest
May 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4.  
  5. int main (void)
  6. {
  7. int value,spin;
  8. double bet,total;
  9.  
  10.  
  11. // start of the loop.
  12.  
  13. while (total!=0)
  14. {
  15. // asking for the number to bet on.
  16. printf("place your bet on a number between 0 and 36:\n");
  17. scanf("%d",&value);
  18.  
  19. while (value<0 || value>36)
  20. {
  21. printf("place your bet on a number between 0 and 36:\n");
  22. scanf("%d",&value);
  23. }
  24.  
  25. // user enters the bet
  26. printf("Enter a bet in dollars $:\n");
  27. scanf("%lf",&bet);
  28.  
  29. srand(time(NULL));
  30. spin=rand()%36;
  31.  
  32.  
  33.  
  34. if (bet==0.0) // if the bet is entered as 0.0 the program quits.
  35. {
  36. printf("\nThank you for playing. You leave the table with $%.2f.\n",total);
  37. return 0;
  38. }
  39.  
  40. if (spin==value)
  41. {
  42. total +=(bet*5);
  43. total=fabs(total);
  44. printf("\nThe result of the spin is %d\n",spin);
  45. printf("\nyou now have $%.2f to game with.\n\n",total);
  46. }
  47.  
  48. else if (value%2==0 && spin%2==0 && value!=0 && spin!=0)
  49. {
  50. total += bet;
  51. total=fabs(total);
  52. printf("\nThe result of the spin is %d\n",spin);
  53. printf("you now have $%.2f to game with.\n\n",total);
  54. }
  55.  
  56. else if ( (value%2==1) && (spin%2==1) && (value!=0) && (spin!=0))
  57. {
  58. total+= bet;
  59. total=fabs(total);
  60. printf("\nThe result of the spin is %d\n",spin);
  61. printf("you now have $%.2f to game with.\n\n",total);
  62. }
  63. else
  64. {
  65. total-=bet;
  66. printf("\nThe result of the spin is %d\n",spin);
  67. printf("you now have $%.2f to game with.\n\n",total);
  68. }
  69. }
  70. return 0;
  71.  
  72. }
Add Comment
Please, Sign In to add comment