<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3.  
  4. Take the 8 inputs
  5. Set the 8 inputs into 4 pairs of numbers
  6. For each pair, set the first number as the bet number
  7. For each pair, set the second number as the money amount
  8. Generate a random number
  9. Make sure the random number is between 1 and 36 or 0 or 00
  10. Set random number = winning number
  11.  
  12. Display winning number
  13. Display user bet number
  14. Display user bet amount
  15.  
  16. IF
  17. Input values missing
  18.    THEN
  19.    Display error message
  20. END IF
  21. IF
  22. Two or more bet numbers are equal
  23.    THEN
  24.    Display error message
  25. END IF
  26. IF
  27. Bet number is less than 0 or greater than 36
  28.    THEN
  29.    Display error message
  30. END IF
  31. IF
  32. Bet money is a negative value
  33.    THEN
  34.    Display error message
  35. END IF
  36.  
  37. IF
  38.    Bet number equals to the winning number
  39.    THEN
  40.   Multiply bet amount by 36 and add this value to total money
  41.    Display payout value from winning bet
  42.    Display bet amount from non winning bets
  43.    Subtract bet amount from non winning bets and bet amount from winning bet away from total money 
  44.    Display total money
  45.    ELSE
  46.    Subtract all bet amount from 0 and add this value to total money
  47.    Display total money
  48. END IF
  49.    
  50. END
  51. */
  52.  
  53.  
  54. #include <stdio.h>
  55. #include <time.h>
  56.  
  57. int main (void)
  58.  
  59. {
  60.  
  61. srand(time(NULL));
  62.  
  63. int bet1,bet2,bet3,bet4,winningnumber;
  64. float money1, money2, money3, money4, payout1, payout2, payout3, payout4, total0, total1, total2, total3, total4;
  65.  
  66.    
  67.  
  68. /*Error message when input is missing*/
  69.  
  70. if (scanf ("%d %f %d %f %d %f %d %f", &bet1,&money1,&bet2,&money2,&bet3,&money3,&bet4,&money4) !=8){
  71.       printf("Missing input value/s!");
  72. }
  73.  
  74. /*Error message when bet numbers are equal*/
  75.  
  76. else if (bet1 == bet2 || bet1 == bet3 || bet1 == bet4 || bet2 == bet3 || bet2 == bet4 || bet3 == bet4){
  77.       printf("Error! Bet numbers should not be the same!\n");
  78.  
  79. /*Error message when bet numbers are equal AND out of range*/
  80.       if(bet1<0 ||bet1>36 || bet2<0 ||bet2 >36 || bet3<0 || bet3>36|| bet4<0 ||bet4>36) {
  81.       printf("Error! Bet number should be between 00 and 36 only! ");
  82.       }
  83. /*Error message when bet number is out of range*/
  84.    } 
  85. else if (bet1<0 ||bet1>36 || bet2<0 ||bet2 >36 || bet3<0 || bet3>36|| bet4<0 ||bet4>36) {
  86.       printf("Error! Bet numbers should be between 00 and 36 only!");
  87.    }
  88. else if (money1<0 || money2<0 || money3<0 || money4<0) {
  89.       printf("Error! Bet money should be a positive value!");
  90.    }
  91.  
  92. else
  93. {
  94.  
  95. winningnumber = (rand()%37) ;       /*Winning number in the roulette wheel*/
  96.  
  97. printf("THE ROULETTE WHEEL IS SPINNING!!! \nWAIT FOR IT.............\nWAIT FOR IT.......\nWAIT FOR IT...\n");
  98.  
  99. printf("THE BALL LANDS ON %d!\n- - - - - - - - - - - - - - - - - - - - -\n- - - - - - - - - - - - - - - - - - - - -\n", winningnumber);
  100.  
  101. /*(35/1 of original bet + original bet) back if winning number = bet number*/
  102.  
  103. payout1 = (36*money1)
  104. payout2 = (36*money2);
  105. payout3 = (36*money3);
  106. payout4 = (36*money4);
  107.  
  108. /*Calculations for net profit/loss value after bets*/
  109.  
  110. total0 = 0 - (money1+money2+money3+money4)
  111. total1 = payout1-money1-money2-money3-money4;
  112. total2 = payout2-money1-money2-money3-money4;
  113. total3 = payout3-money1-money2-money3-money4;
  114. total4 = payout4-money1-money2-money3-money4;
  115.  
  116. /*If statements when a bet = winning number / no bet = winning number*/
  117. printf("Your FIRST bet number is %d\n", bet1);
  118. printf("Bet amount = %.2f\n", money1);
  119.  
  120. if (bet1 == winningnumber) {
  121. printf("Congratulations!\nYou get %.2f\n", payout1);
  122. }
  123. else { printf("You lose %.2f\n", money1);
  124. }
  125.  
  126. printf("=======================================\n");
  127. printf("Your SECOND bet number is %d\n", bet2);
  128. printf("Bet amount = %.2f\n", money2);
  129.  
  130. if (bet2 == winningnumber) {
  131. printf("Congratulations!\nYou get %.2f\n", payout2);
  132. }
  133. else { printf("You lose %.2f\n", money2);
  134. }
  135.  
  136. printf("=======================================\n");
  137. printf("Your THIRD bet number is %d\n", bet3);
  138. printf("Bet amount = %.2f\n", money3);
  139.  
  140. if (bet3 == winningnumber) {
  141. printf("Congratulations!\nYou get %.2f\n", payout3);
  142. }
  143. else { printf("You lose %.2f\n", money3);
  144. }
  145.  
  146. printf("=======================================\n");
  147. printf("Your FOURTH bet number is %d\n", bet4);
  148. printf("Bet amount = %.2f\n", money4);
  149.  
  150.  
  151. if (bet4 == winningnumber) {
  152. printf("Congratulations!\nYou get %.2f\n", payout4);
  153. }
  154. else { printf("You lose %.2f\n\n", money4);
  155. }
  156.  
  157. if (bet1 == winningnumber) {
  158. printf("=======================================\n");
  159. printf ("Your net profit is %.2f\n\n", total1);
  160. }
  161. else if (bet2 == winningnumber) {
  162. printf("=======================================\n");
  163. printf("Your net profit is %.2f\n\n", total2);
  164. }
  165. else if (bet3 == winningnumber) {
  166. printf("Your net profit is %.2f\n\n", total3);
  167. }
  168. else if (bet4 == winningnumber) {
  169. printf("=======================================\n");
  170. printf("Your net profit is %.2f\n\n", total4);
  171. }
  172. else
  173.  
  174. {
  175. printf("=======================================\n");
  176. printf ("Your net profit is %.2f\n\n", total0);   
  177. }
  178.  
  179. printf("SPIN AGAIN?");
  180. }
  181.  
  182. }