<mosaic.cnfolio.com>
PROGRAM
  1. /* Pseudo Code
  2. Start
  3.    Read the bet numbers and bet amounts
  4.    Simulate a game of roulette
  5.       IF the first bet number is higher than required
  6.       IF the second bet number is higher than required
  7.       IF the third bet number is higher than required
  8.       IF the fourth bet number is higher than required
  9.          IF the bet number is the same as the generated number and the bet value is greater than zero
  10.             Perform the winning calculation
  11.             Display information about the bet
  12.             Display the winnings for the bet
  13.          ELSE
  14.          IF the bet number is not the same as the generated number and the bet amount is bigger than zero
  15.             Perform the loss calculation
  16.             Display information about the bet
  17.             Display the loss for the bet
  18.          END IF
  19.          IF the bet number is the same as the generated number and the bet value is greater than zero
  20.             Perform the winning calculation
  21.             Display information about the bet
  22.             Display the winnings for the bet
  23.          ELSE
  24.          IF the bet number is not the same as the generated number and the bet amount is bigger than zero
  25.             Perform the loss calculation
  26.             Display information about the bet
  27.             Display the loss for the bet
  28.          END IF
  29.          IF the bet number is the same as the generated number and the bet value is greater than zero
  30.             Perform the winning calculation
  31.             Display information about the bet
  32.             Display the winnings for the bet
  33.          ELSE
  34.          IF the bet number is not the same as the generated number and the bet amount is bigger than zero
  35.             Perform the loss calculation
  36.             Display information about the bet
  37.             Display the loss for the bet
  38.          END IF
  39.          IF the bet number is the same as the generated number and the bet value is greater than zero
  40.             Perform the winning calculation
  41.             Display information about the bet
  42.             Display the winnings for the bet
  43.          ELSE
  44.          IF the bet number is not the same as the generated number and the bet amount is bigger than zero
  45.             Perform the loss calculation
  46.             Display information about the bet
  47.             Display the loss for the bet
  48.          END IF
  49.       IF the final winnings are greater than zero
  50.          Perform the final winnings calculation
  51.          Display the final winnings
  52.       END IF
  53.       ELSE
  54.          Display an error message to notify the user about the mistake
  55.       END IF
  56.       ELSE
  57.          Display an error message to notify the user about the mistake
  58.       END IF
  59.       ELSE   
  60.          Display an error message to notify the user about the mistake
  61.       END IF
  62.       ELSE
  63.          Display an error message to notify the user about the mistake
  64.       END IF   
  65. END
  66. */
  67. #include <stdio.h>
  68. #include <stdlib.h>
  69. #include <time.h>
  70.    
  71.     int main(void)
  72.     {
  73.         int number;               /* Generated random number */
  74.         int bet1, bet2, bet3, bet4;                         /* Number which a player is betting on. */
  75.         int betAmount1, betAmount2, betAmount3, betAmount4; /* How much money a player is putting on the number. */
  76.         int Winnings1, Winnings2, Winnings3, Winnings4;   /* Represents each bet winnings */
  77.         int TotalWin;                           /* Represents the total win/loss in the game */
  78.  
  79.         scanf("%d %d %d %d %d %d %d %d", & bet1, & betAmount1, & bet2, & betAmount2, & bet3, & betAmount3, & bet4, & betAmount4);
  80.                                                             
  81.         srand(time(0));
  82.  
  83.         do
  84.         {
  85.         number = rand();                                    /* Random number generator to generate numbers for the program. */
  86.         }
  87.         while (number >= 36);           /* Statment is asking to generate numbers which are greater or equal to 36. */
  88.        
  89.         if ( bet1 <= 37 )                        /* Statments checking if the bet numbers are equal to or under 37, in order to progress. */
  90.         {
  91.         if ( bet2 <= 37 )
  92.         {
  93.         if ( bet3 <= 37 )
  94.         {
  95.         if ( bet4 <= 37 )
  96.         {
  97.  
  98.         /* Start of the bets */
  99.         if (bet1 == number && betAmount1 > 0)           /* Statment checking if the generated number is the same as entered bet number, also checking if the bet amount entered is higher than zero. */
  100.         {
  101.             Winnings1 = (betAmount1 * 36) - betAmount1;    /* This is the winning calculation if above statment is true. */
  102.             printf("\nYou betted %d on bet 1. The ball landed on number %d, which means you won!\n", betAmount1, number);  /* Information message letting the user know the most importnt details about the bet. */
  103.             printf("The Winnings for bet 1 are: %d after taking away your initial bet amount!", Winnings1);                  /* Information message to display final payout value for the bet. */
  104.         }
  105.         else
  106.         {
  107.         if (bet1 != number && betAmount1 > 0);      /* Statment asking if the generated number is not the same as entered bet number, also chacking if the bet amount entered is higher than zero. */
  108.         {
  109.             Winnings1 = -betAmount1;                        /* This is the loss calculation if the above statment is true. */
  110.             printf("\nYou betted %d on bet 1. The ball landed on number %d, your number was %d, which means you didn't win this bet.\n", betAmount1, number, bet1);  /* Information message letting the user know the most importnt details about the bet. */
  111.             printf("Unfortunately you lost your initial bet amount. You lost %d on this bet.", Winnings1);                     /* Information message to display final payout value for the bet. */
  112.         }
  113.         }                                                   /* The end of the bet. */
  114.         /* Above bet comments are the same for the remaining three bets. */
  115.  
  116.         if (bet2 == number && betAmount2 > 0)
  117.         {
  118.             Winnings2 = (betAmount2 * 36) - betAmount2;
  119.             printf("\nYou betted %d on bet 2. The ball landed on number %d, which means you won!\n", betAmount2, number);
  120.             printf("The Winnings for bet 2 are: %d after taking away your initial bet amount!", Winnings2);
  121.         }
  122.         else
  123.         {
  124.         if (bet2 != number && betAmount2 > 0);
  125.         {
  126.             Winnings2 = -betAmount2;
  127.             printf("\nYou betted %d on bet 2. The ball landed on number %d, your number was %d, which means you didn't win this bet.\n", betAmount2, number, bet2);
  128.             printf("Unfortunately you lost your initial bet amount. You lost %d on this bet.", Winnings2);
  129.         }
  130.         }
  131.  
  132.         if (bet3 == number && betAmount3 > 0)
  133.         {
  134.             Winnings3 = (betAmount3 * 36) - betAmount3;
  135.             printf("\nYou betted %d on bet 3. The ball landed on number %d, which means you won!\n", betAmount3, number);
  136.             printf("The Winnings for bet 3 are: %d, after taking away your initial bet amount!", Winnings3);
  137.         }
  138.         else
  139.         {
  140.         if (bet3 != number && betAmount3 > 0);
  141.         {
  142.             Winnings3 = -betAmount3;
  143.             printf("\nYou betted %d on bet 3. The ball landed on number %d, your number was %d, which means you didn't win this bet.\n", betAmount3, number, bet3);
  144.             printf("Unfortunately you lost your initial bet amount. You lost %d on this bet.", Winnings3);
  145.         }
  146.         }
  147.        
  148.         if (bet4 == number && betAmount4 > 0)
  149.         {
  150.             Winnings4 = (betAmount4 * 36) - betAmount4;
  151.             printf("\nYou betted %d on bet 4. The ball landed on number %d, which means you won!\n", betAmount4, number);
  152.             printf("The winnings for bet 4 are: %d, after taking away your initial bet amount!", Winnings4);
  153.         }
  154.         else
  155.         {
  156.         if (bet4 != number && betAmount4 > 0);
  157.         {
  158.             Winnings4 = -betAmount4;
  159.             printf("\nYou betted %d on bet 4. The ball landed on number %d, your number was %d, which means you didn't win this bet.\n", betAmount4, number, bet4);
  160.             printf("Unfortunately you lost your initial bet amount. You lost %d on this bet.", Winnings4);
  161.         }
  162.         }
  163.        
  164.         if ( TotalWin >= 0 )                          /* Statment asking if the total win value is greater than zero. */
  165.         {
  166.             TotalWin = Winnings1+Winnings2+Winnings3+Winnings4;   /* This is the final payout value calculation. */
  167.             printf("\nYour final profit/loss at the end of the game is: %d in this game.\n", TotalWin );      /* A message to notify the user about how much it has won/lost during the game. */
  168.         }
  169.        
  170.         }                                                         /* Finish point of the IF statment which is checking if the bet number is less than or equal to 37. */
  171.         else                                                      /* This statment is asking if the first IF statment is true. */
  172.         {
  173.           printf("\nPlease enter a bet number which equals or is less than 37!\n");      /* An error message will be displayed if the bet number is higher or not equal to 37. */
  174.         }
  175.         /* The above comments are the same for the below 3 ELSE statments. */
  176.        
  177.         }
  178.         else
  179.         {
  180.           printf("\nPlease enter a bet number which equals or is less than 37!\n");
  181.         }
  182.        
  183.         }
  184.         else
  185.         {
  186.           printf("\nPlease enter a bet number which euqals or is less than 37!\n");
  187.         }
  188.        
  189.         }
  190.         else
  191.         {
  192.           printf("\nPlease enter a bet number which equals or is less than 37!\n");
  193.         }
  194.        
  195.     }