<mosaic.cnfolio.com>
PROGRAM
  1. /*START
  2.  
  3. IF bet inputs is less than 8
  4.   Display error message
  5. ELSE
  6.    Get bet numbers and bet amounts
  7. IF bet numbers are between 0 and 36
  8. AND bet amount is above 0
  9.     Spin roulette wheel with slots for 0 - 36 and 00
  10.     Display bet numbers and bet amounts
  11.     Display winning number
  12. IF any bet number is equal to the winning number
  13.   THEN multiply bet amount by 35 and display value as payout value
  14.   ELSE
  15.     Display you have lost your bet amount
  16.     Display payout value as 0 */
  17.  
  18. #include <stdio.h>
  19. #include <time.h>
  20. #include <stdlib.h>
  21.  
  22. int main(void) {
  23.    
  24. char bet[3];
  25. float amount1, amount2, amount3, amount4, amount5, amount6;
  26. float payout1, payout2, payout3, payout4;
  27. float totalloss1, totalloss2, totalloss3, totalloss4;
  28. int wN, i, j;
  29. float totalloss;
  30. float totalwinnings, totalwn, totalwn1, totalpayout;
  31. {{ printf("place your bets!\n");
  32.  
  33. i = scanf("%f %i %f %i %f %i %f %i", &amount1, &bet[0], &amount2, &bet[1], &amount3, &bet[2], &amount4, &bet[3]);
  34.     scanf("%f %f", &amount5, &amount6);
  35.    
  36.   if (i < 8) {printf("invalid input"); return (0);}
  37.   else {printf("%.2f on %i, %.2f on %i, %.2f on %i, %.2f on %i\n",amount1, bet[0], amount2, bet[1], amount3, bet[2], amount4, bet[3]);
  38.   }
  39.    printf("%.2f on red, %.2f on black\n", amount5, amount6);
  40.          
  41.   srand(time(NULL)); wN = rand() % 37;
  42.          printf("winnning number is %d\n", wN);
  43.          
  44.    j =  wN == 1||wN == 3||wN == 5||wN == 7||wN == 9||wN ==12||
  45.     wN ==14||wN ==16||wN ==18||wN ==19||wN ==21||wN ==23||
  46.     wN ==25||wN ==27||wN ==30||wN ==32||wN ==34||wN ==36 ;
  47.        
  48.  if( j ){ printf("winning colour is black payout is %.2f\nyou have lost %.2f on red\n", amount6, amount5);}
  49.  else {
  50.         printf("winning colour is red payout is %.2f\nyou have lost %.2f on black\n", amount5, amount6);}}
  51.        
  52.       if (j) {totalwn = amount6;}
  53.       else {totalwn = amount5;}
  54.              if (j) {totalwn1 = amount5;}
  55.              else {totalwn1 = amount6;}
  56.        
  57.         totalloss1 = amount2+amount3+amount4+totalwn1;         
  58.      if ( bet[0] == wN )
  59.        {printf("you have won with bet1!\n");
  60.         payout1 = amount1*35;
  61.         printf("payout is %.2f\n", payout1);
  62.         printf("total loss = %.2f\n", totalloss1);}
  63.      else
  64.        {payout1 = 0;
  65.         printf("BET1: you have lost %.2f\n", amount1);
  66.         totalloss1= 0;}
  67.      
  68.         totalloss2 = amount1+amount3+amount4+totalwn1;
  69.      if ( bet[1] == wN )
  70.        {printf("you have won with bet2!\n");
  71.         payout2 = amount2*35;
  72.         printf("payout is %.2f\n", payout2);
  73.         printf("total loss = %.2f\n", totalloss2);}
  74.      else
  75.        {payout2 = 0;
  76.         printf("BET2: you have lost %.2f\n", amount2);
  77.         totalloss2= 0;}
  78.        
  79.         totalloss3 = amount2+amount1+amount4+totalwn1;
  80.      if ( bet[2] == wN )
  81.        {printf("you have won with bet3!\n");
  82.         payout3 = amount3*35;
  83.         printf("payout is %.2f\n", payout3);
  84.         printf("total loss = %.2f\n", totalloss3);}
  85.      else
  86.        {payout3 = 0;
  87.         printf("BET3: you have lost %.2f\n", amount3);
  88.         totalloss3= 0;}
  89.        
  90.         totalloss4= amount2+amount3+amount1+totalwn1;
  91.      if ( bet[3] == wN )
  92.        {printf("you have won with bet4!\n");
  93.         payout4 = amount4*35;
  94.         printf("payout is %.2f\n", payout4);
  95.         printf("total loss = %.2f\n", totalloss4);}
  96.      else
  97.        {payout4 = 0;
  98.         printf("BET4: you have lost %.2f\n", amount4);
  99.         totalloss4= 0;}
  100.        
  101.        totalwinnings = payout1+payout2+payout3+payout4+totalwn;
  102.              printf("total winnings = %.2f\n", totalwinnings);
  103.        
  104.        totalpayout =  payout1+payout2+payout3+payout4+totalwn;
  105.              printf("total profit = %.2f", totalpayout-totalloss1-totalloss2-totalloss3-totalloss4);}}