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