<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3. Set number of bets to zero
  4. WHILE number of bets is less than 4
  5.   Get bet number and bet value
  6.   IF bet number is between zero and 35 AND
  7.      bet value is a positive whole number
  8.   THEN   
  9.      Spin wheel using table with pockets for 0 to 36
  10.      Display bet number
  11.      Display bet amount
  12.      Display winnning number
  13.      IF bet number equals winning number
  14.        THEN
  15.          Add bet value to pocket
  16.          Add bet value multiplied by 35 to pocket value
  17.          Display bet value multiplied by 35 as payout value
  18.        ELSE
  19.          Substract bet value from pocket value
  20.          Display zero as payout value
  21.      END IF 
  22.     Dsplay pocket value
  23.     Icrease number of bets by one
  24.   ELSE
  25.     display error massage about incorrect bet input
  26.   END IF
  27. END WHILE
  28. IF number of bets is less than 4
  29.   THEN
  30.    Display error message about lack of inputs bets
  31. END IF
  32. Display final value
  33. END
  34. */
  35.  
  36.  
  37. #include <stdio.h>
  38.  
  39. int walletMoney = 300;
  40.  
  41. int main( void )
  42. {
  43.    int betNumber1;
  44.    int betNumber2 = 0;
  45.    int betNumber3 = 0;
  46.    int betNumber4 = 0;
  47.    int betNumber5 = 0;
  48.    int betNumber6 = 0;
  49.    int betNumber7 = 0;
  50.    int betNumber8 = 0;
  51.    int betAmount1 = 0;
  52.    int betAmount2 = 0;
  53.    int betAmount3 = 0;
  54.    int betAmount4 = 0;
  55.    int winningNumber = 0;
  56.    int amountWon = 0;
  57.  
  58.    // get bet number
  59.    // first bet
  60.    scanf("%d %d %d", &betNumber1, &betNumber2, &betAmount1);
  61.    
  62.    // second bet
  63.    scanf( "%d %d %d", &betNumber3, &betNumber4, &betAmount2);
  64.  
  65.    // third bet
  66.    scanf( "%d %d %d", &betNumber5, &betNumber6, &betAmount3);
  67.    
  68.    // fourth bet
  69.    scanf( "%d %d %d", &betNumber7, &betNumber8, &betAmount4);
  70.  
  71.    printf("BETTING INFORMATION\n");
  72.    // display total amount bet and bet numbers
  73.    printf( "Your have bet on the following numbers: %d %d %d %d %d %d %d %d", betNumber1, betNumber2, betNumber3, betNumber4, betNumber5, betNumber6, betNumber7, betNumber8);
  74.    printf( "\nYour total bet amount: %d", (betAmount1 + betAmount2 + betAmount3 + betAmount4));
  75.    
  76.    //subtract bet total amount from wallet
  77.    walletMoney = walletMoney - (betAmount1 + betAmount2 + betAmount3 + betAmount4);
  78.    printf( "\nYour new balance after placing the bet is %d", walletMoney);
  79.       
  80.    /* The rand() function is called each time a new random number is required. */
  81.    srand(time(NULL));
  82.    winningNumber = rand() % 37;
  83.  
  84.    // display the winning number (0 - 36)
  85.    printf( "\n\nSPINNING THE WHEEL");
  86.    printf( "\nWinning Number this round: %d", winningNumber);
  87.    
  88.    
  89.    // game of rulette
  90.    // first bet
  91.    if(winningNumber == betNumber1 || winningNumber == betNumber2){
  92.       printf("\nYour first bet pair(%d & %d) won: %d!", betNumber1, betNumber2, (betAmount1 * 35));
  93.       amountWon += (betAmount1 * 35);
  94.    }
  95.    
  96.    // second bet
  97.    if(winningNumber == betNumber3 || winningNumber == betNumber4){
  98.       printf("\nYour second bet pair(%d & %d) won: %d!", betNumber3, betNumber4, (betAmount2 * 35));
  99.       amountWon += (betAmount2 * 35);
  100.    }
  101.    
  102.    // third bet
  103.    if(winningNumber == betNumber5 || winningNumber == betNumber6){
  104.       printf("\nYour third bet pair(%d & %d) won: %d!", betNumber5, betNumber6, (betAmount3 * 35));
  105.       amountWon += (betAmount3 * 35);
  106.    }
  107.    
  108.    // fourth bet
  109.    if(winningNumber == betNumber7 || winningNumber == betNumber8){
  110.       printf("\nYour fourth bet pair(%d & %d) won: %d!", betNumber7, betNumber8, (betAmount4 * 35));
  111.       amountWon += (betAmount4 * 35);
  112.    }
  113.    
  114.    printf("\n\nROUND REPORT:");
  115.    if(amountWon == 0){
  116.       printf("\nYou did not won any money this round");
  117.       printf("\nYou lost %d this round", (betAmount1 + betAmount2 + betAmount3 + betAmount4));     
  118.    }
  119.    else{
  120.       printf("\nTotal EARNINGS: %d", amountWon);
  121.       printf("\nYou have made %d profit", (amountWon - (betAmount1 + betAmount2 + betAmount3 + betAmount4)));
  122.       walletMoney = walletMoney + amountWon;
  123.    }
  124.    
  125.    printf("\nWallet amount: %d", walletMoney);
  126.    
  127.    if(betNumber1<0) {
  128.      printf("\n\nError: Your First bet number is less than 0 \n\n Please enter a number between 0 and 36 \n");}
  129.    if(betNumber2<0) {
  130.      printf("\n\nError: Your Second bet number is less than 0 \n\n Please enter a number between 0 and 36 \n");}
  131.    if(betNumber3<0) {
  132.       printf("\n\nError: Your Third bet number is less than 0 \n\n Please enter a number between 0 and 36 \n");}
  133.    if(betNumber4<0) {
  134.       printf("\n\nError: Your Fourth bet number is less than 0 \n\n Please enter a number between 0 and 36 \n");}
  135.    if(betNumber5<0) {
  136.       printf("\n\nError: Your Fifth bet number is less than 0 \n\n Please enter a number between 0 and 36 \n");}
  137.    if(betNumber6<0) {
  138.       printf("\n\nError: Your Sixth bet number is less than 0 \n\n Please enter a number between 0 and 36 \n");}
  139.    if(betNumber7<0) {
  140.       printf("\n\nError: Your Seventh bet number is less than 0 \n\n Please enter a number between 0 and 36 \n");}
  141.    if(betNumber8<0) {
  142.       printf("\n\nError: Your Eighth bet number is less than 0 \n\n Please enter a number between 0 and 36 \n");} 
  143.      
  144.    if(betNumber1>36) {
  145.       printf("\n\nError: Your First bet number is more than 36 \n\n Please enter a number between 0 and 36 \n");}
  146.    if(betNumber2>36) {
  147.       printf("\n\nError: Your Second bet number is more than 36 \n\n Please enter a number between 0 and 36 \n");}
  148.    if(betNumber3>36) {
  149.       printf("\n\nError: Your Third bet number is more than 36 \n\n Please enter a number between 0 and 36 \n");}
  150.    if(betNumber4>36) {
  151.       printf("\n\nError: Your Fourth bet number is more than 36 \n\n Please enter a number between 0 and 36 \n");}
  152.    if(betNumber5>36) {
  153.       printf("\n\nError: Your Fifth bet number is more than 36 \n\n Please enter a number between 0 and 36 \n");}
  154.    if(betNumber6>36) {
  155.       printf("\n\nError: Your Sixth bet number is more than 36 \n\n Please enter a number between 0 and 36 \n");}
  156.    if(betNumber7>36) {
  157.       printf("\n\nError: Your Seventh bet number is more than 36 \n\n Please enter a number between 0 and 36 \n");} 
  158.    if(betNumber8>36) {
  159.       printf("\n\nError: Your Eighth bet number is more than 36 \n\n Please enter a number between 0 and 36 \n");} 
  160.      
  161.      
  162. }