<mosaic.cnfolio.com>
PROGRAM
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include (time.h>
  4.  
  5. int main(void)
  6.  
  7. {
  8. //dounbles for money
  9. double startmoney;
  10. double account;
  11. double moneybet;
  12. double winning;
  13.  
  14. //intergers for betting
  15. int oddeven;
  16. int number;
  17. int x;
  18. int exit;
  19. int bet;
  20.  
  21. print("\nPick the amount of money you want to begin with: $");
  22. //select the amount of money you want to start with
  23. scanf("%lf", &startmoney);
  24.  
  25. account=startmoney;
  26. //loop to carry on the game while the player has their money
  27. while(account>0)
  28. {
  29. srand(time(0));
  30. printf("\nEnter your bet: $");
  31. scanf("%lf", &moneybet);
  32. //asking for the amount of money the play would like to bet with
  33. printf("\nSelect: 1 to bet on odd\n 2 to bet on even\n 3 to bet on a selected number number\n.");
  34. //asking the player what type of bet they would like yo start with
  35. scanf("%lf", bet);
  36. //loop for the oddeven bet
  37. if (bet==1)
  38. {
  39. x=rand() % 38;
  40. printf("The ball landed on %i\n", x);
  41. oddeven=x%2;
  42. //loop only if the player looses the bet of a green slot
  43. if(x==37||x==0)
  44. {
  45. winning=0;
  46. account=account-moneybet;
  47. printf("Player landed on a green slot.");
  48. printf("Player lost their bet.");
  49. printf("\Player now has $%.2lf:", account);
  50. }
  51. //loop only if the player chooses the odd slot
  52. if(oddeven!=0&&x!=0&&x!=37)
  53. {
  54. winning=moneybet;
  55. account=winning+account;
  56. printf("\nThe ball landed on odd.");
  57. printf("\nPlayers total winnings is $%.2lf.",winning);
  58. printf("\nPlayers current account is now $%.2lf", account);
  59. }
  60. //loop only if the player looses on a odd slot
  61. else
  62. {
  63. winning=0;
  64. account=account-moneybet;
  65. printf("\nSorry, you lost the round $%.2lf");
  66. printf("\nPlayers current account is now $%.2lf",account);
  67. }
  68. }
  69. //loop only if the player choose a even slot
  70. if(bet==2)
  71. {
  72. x=rand()%38;
  73. printf("The ball has landed on %i", x);
  74. oddeven=x%2;
  75. //loop only if the player losses their bet by landing on a green slot
  76. if(x==37||X==0)
  77. {
  78. winning=0;
  79. account=account-moneybet;
  80. printf("\nPlayer landed on a green slot.");
  81. printf("\nPlayer lost their bet.");
  82. printf("\nPlayer current account is now $%.2lf", account);
  83. }
  84. else
  85. if(oddeven==0&&x!=0&&x!=37)
  86. {
  87. winning=moneybet;
  88. acount=winning+account;
  89. printf("\nPlayer won their bet.");
  90. print("\nPlayers winnings are $%.2lf", winning);
  91. printf("\nPlayer account balance is now $%.2lf", account);
  92. }
  93. else
  94. {
  95. winning=account-moneybet;
  96. account=account=winning;
  97. printf("\nSorry you lost.");
  98. printf("\nPlayers account balance is now $%.2lf",account);
  99. }
  100. }
  101. // loop only if player chooses an exact number to bet on
  102. if(bet==3)
  103. {
  104. printf("\nPlayer needs to enter the number they would like to bet on (1- 36 only): ");
  105. scanf("%i",number);
  106. x=rand()%38;
  107. printf("\nThe ball landed on %i", x);
  108. //if the player loose by ladning on 37 or a 0
  109. if(x==37||x==0)
  110. {
  111. winning=0;
  112. account=account-moneybet;
  113. printf("\nPlayer landed on a green slot");
  114. printf("\nPlayer lost their bet.");
  115. printf("\nPlayers account balance is now $%.2lf", account);
  116. }
  117. //loop only if player wins their number
  118. if(x==number&&x!=0&&x!=37)
  119. {
  120. winning=account+moneybet;
  121. printf("\nPlayer have won your bet.");
  122. printf("\nPlayers winning are $%.2lf", winning);
  123. printf("\nPlayers account blance is now $%.2lf", account);
  124. }
  125. //loop only if player looses their number
  126. else
  127. {
  128. account=account-moneybet;
  129. printf("\nSorry you lost.");
  130. printf("\nPlayers account blance is now $%.2lf", account);
  131. }
  132. }
  133. //prompt to exit
  134. printf("Enter 0 to quit, 1 to continue playing:");
  135. scanf("%i", &exit);
  136. if(exit=0)
  137. {
  138. return 0;
  139. }
  140. }
  141. return 0;
  142. }