<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3. SET number of bets to zero
  4. Get bet number and bet value
  5. Display the welcome message
  6. IF bet number is between 0 and 36  AND
  7. bet value is between 0 and 500
  8.  
  9.    THEN
  10.       Spin roulette wheel using table with pockets for 0 to 36 and a pocket for 00
  11.       Display winning number
  12.       IF bet number equal winning number
  13.      
  14.          THEN
  15.             Display the winning message
  16.             Multiply the bet value by 35
  17.             Display bet value multiplied by 35 as payout value
  18.  
  19.          ELSE
  20.             Display the loss message
  21.             multiply the bet value by -1
  22.             Display zero as the payout value
  23.             Display the luck wishing message
  24.            
  25.       END IF
  26.          Display total amount of bet value
  27.          
  28.      ELSE
  29.      Display error message about incorrect input value
  30.      
  31.    END IF
  32. END
  33. */
  34.  
  35.  
  36. /* processor commands*/
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <time.h>
  40.  
  41. /*the main function*/
  42. int main()
  43. {
  44.     /*variables*/
  45.    int betamt1 = 0;
  46.    int betamt2 = 0;
  47.    int betamt3 = 0;
  48.    int betamt4 = 0;
  49.    int gainloss1 = 0;
  50.    int gainloss2 = 0;
  51.    int gainloss3 = 0;
  52.    int gainloss4 = 0;
  53.    int totalgainloss = 0;
  54.    int moneywon1 = 0;
  55.    int moneywon2 = 0;
  56.    int moneywon3 = 0;
  57.    int moneywon4 = 0;
  58.    int totalmoneywon = 0;
  59.    int   bet1 =0;
  60.    int   bet2 =0;
  61.    int   bet3 =0;
  62.    int   bet4 =0;
  63.  
  64.   /*Random number generator*/
  65.    srand(time(0));
  66.       int r = rand()%36;
  67.  
  68.          if(r==36)
  69.          {
  70.          r=00;
  71.          }
  72.        
  73.        /*the welcome message*/
  74.    printf("Welcome to the American roulette.\nPlease enter a number of 4 bets and the amount for each.\n");
  75.       
  76.       /*input functions*/
  77.    scanf("%d", &betamt1);
  78.    scanf("%d", &bet1);
  79.    scanf("%d", &betamt2);
  80.    scanf("%d", &bet2);
  81.    scanf("%d", &betamt3);
  82.    scanf("%d", &bet3);
  83.    scanf("%d", &betamt4);
  84.    scanf("%d", &bet4);
  85.    
  86.       /*Error messages*/
  87.     if (bet1<0||bet2<0||bet3<0||bet4<0)
  88.    {
  89.    printf("Error! please enter a valid bet number\n");
  90.    exit(0);
  91.    }
  92.    if (bet1>36||bet2>36||bet3>36||bet4>36)
  93.    {
  94.    printf("Error! please enter a valid bet number\n");
  95.    exit(0);
  96.    }
  97.    
  98.    if (betamt1<1||betamt2<1||betamt3<1||betamt4<1)
  99.    {
  100.    printf("Error! Please enter a minimum bet amount of $1\n");
  101.    exit(0);
  102.    }
  103.    if (betamt1>500||betamt2>500||betamt3>500||betamt4>500)
  104.    {
  105.    printf("Alert! Maximun bet amount allowed is $500\n");
  106.    exit(0);
  107.    }
  108.    
  109.    printf("The winning number is %d\n",r);
  110.    
  111.          /*sequence for the first bet win*/
  112.       if (bet1==r)
  113.          {
  114.          moneywon1 = (betamt1 + (35 * betamt1));
  115.          printf("\nCongratulations!!! Bet1 has won.");
  116.          printf("\nYou've won a total of $%d", moneywon1);
  117.          gainloss1 = (moneywon1 - betamt1);
  118.          printf("\nThe amount of money gained is $%d\n", gainloss1);
  119.          }
  120.       else /*sequence for the first bet loss*/
  121.          {
  122.          printf("\nSorry! Bet1 has lost.");
  123.          gainloss1 = (-1 * betamt1);
  124.          printf("\nThe amount of money lost is %d", gainloss1);
  125.          printf("\nWish you a better luck next time.\n");
  126.          betamt1 = 0;
  127.          }
  128.          
  129.       if (bet2==r) /*sequence for the second bet win*/
  130.          {
  131.          moneywon2 = (betamt2 + (35 * betamt2));
  132.          printf("\nCongratulations!!! Bet2 has won.");
  133.          printf("\nYou've won a total of $%d", moneywon2);
  134.          gainloss2 = (moneywon1 - betamt1);
  135.          printf("\nThe amount of money gained is $%d\n", gainloss2);
  136.          }
  137.       else /*sequence for the second bet loss*/
  138.          {
  139.          printf("\nSorry! Bet2 has lost.");
  140.          gainloss2 = (-1 * betamt2);
  141.          printf("\nThe amount of money lost is %d", gainloss2);
  142.          printf("\nWish you a better luck next time.\n");
  143.          betamt2 = 0;
  144.          }
  145.          
  146.       if (bet3==r)/*sequence for the third bet win*/
  147.          {
  148.          moneywon3 = (betamt3 + (35 * betamt3));
  149.          printf("\nCongratulations!!! Bet3 has won.");
  150.          printf("\nYou've won a total of $%d", moneywon3);
  151.          gainloss3 = (moneywon3 - betamt3);
  152.          printf("\nThe amount of money gained is $%d\n", gainloss3);
  153.           }
  154.       else /*sequence for the third bet loss*/
  155.          {
  156.          printf("\nSorry! Bet3 has lost.");
  157.          gainloss3 = (-1 * betamt3);
  158.          printf("\nThe amount of money lost is %d", gainloss3);
  159.          printf("\nWish you a better luck next time.\n");
  160.          betamt3 = 0;
  161.          }
  162.          
  163.       if (bet4==r)/*sequence for the fourth bet win*/
  164.          {
  165.          moneywon4 = (betamt4 + (35 * betamt4));
  166.          printf("\nCongratulations!!! Bet4 has won.");
  167.          printf("\nYou've won a total of $%d", moneywon4);
  168.          gainloss4 = (moneywon4 - betamt4);
  169.          printf("\nThe amount of money gained is $%d\n", gainloss4);
  170.          }
  171.       else /*sequence for the fourth bet loss*/
  172.          {
  173.          printf("\nSorry! Bet4 has lost.");
  174.          gainloss4 = (-1 * betamt4);
  175.          printf("\nThe amount of money lost is %d", gainloss4);
  176.          printf("\nWish you a better luck next time.\n");
  177.          betamt4 = 0;
  178.          }
  179.          
  180.       totalmoneywon = (moneywon1 + moneywon2 + moneywon3 + moneywon4) - (betamt1 + betamt2 + betamt3 + betamt4);
  181.        printf("\nThe total amount of of money won is $%d",totalmoneywon);
  182.        
  183. }