<mosaic.cnfolio.com>
PROGRAM
  1. /* PSEUDO CODE FOR ROULETTE
  2.  
  3. START
  4.  
  5.    Set betNumber (int)
  6.    Set betValue (int)
  7.    Set payoutValue (int)
  8.    Set winningNumber (int)
  9.    Set playerProfit (int)
  10.    Set playerLoss (int)
  11.    Set red (char)
  12.    Set black (char)
  13.    
  14.    DISPLAY "Choose a number between 0 and 36: "
  15.    GET betNumber
  16.    
  17.       If betNumber < 0 or > 36
  18.      
  19.          DISPLAY "Please enter a number between 0 and 36" (betNumber)
  20.            
  21.       IF betNumber == 0-36
  22.            
  23.             THEN
  24.                
  25.                PRINT user input
  26.                
  27.          END IF
  28.            
  29.    DISPLAY "Choose a value over 0" (betValue)
  30.    
  31.    GET betValue
  32.      
  33.       IF betValue < 0
  34.      
  35.                DISPLAY "Please enter a value over 0" (betValue)
  36.      
  37.       IF betValue => 0
  38.      
  39.             THEN
  40.                
  41.                PRINT user input
  42.                
  43.             THEN spin roulette
  44.            
  45.       IF betNumber == winningNumber
  46.        
  47.          THEN
  48.            
  49.             DISPLAY "Congratulations you have won !!!"
  50.            
  51.          THEN
  52.            
  53.             PRINT playerProfit
  54.                   playerProfit == (betValue * 36)
  55.            
  56.       IF betNumber != winningNumber
  57.      
  58.          THEN
  59.            
  60.             DISPLAY "Sorry you haven't won"
  61.             DISPLAY loss for each bet
  62.            
  63.          THEN
  64.            
  65.             PRINT playerLoss
  66.                   playerLoss == (betValue * 35) - betValue
  67.            
  68.       END IF
  69.      
  70.       DISPLAY "Your payout value is: "
  71.      
  72.          payoutValue == playerLoss + playerProfit
  73.      
  74.  
  75. END
  76.  
  77. */
  78.  
  79. #include <stdio.h>
  80. #include <ctype.h>
  81. #include <stdlib.h>
  82. #include <time.h>
  83.  
  84.  
  85. int main(void)
  86.  
  87. {
  88.    
  89.    
  90.    int betNumber1=37, betNumber2=37, betNumber3=37, betNumber4=37; // 0 - 37
  91.    float betValue1, betValue2, betValue3, betValue4; //amount placed on bet
  92.    float totalProfit; //overall profit after all 4 bets
  93.    float totalLoss; //overall loss after all 4 bets
  94.    float payoutValue; //betvalue * 35
  95.    int winningNumber;
  96.    float playerProfit;
  97.    float playerLoss;
  98.    char doubleZero [00];
  99.    
  100.  
  101.    srand( time( 0 ) ); //roulette spinning, random number chosen
  102.  
  103.    winningNumber = rand() % 37;
  104.  
  105.    winningNumber++;
  106.  
  107.    printf( "Winning number is %d \n\n", winningNumber );
  108.  
  109.    scanf("%d", &betNumber1); // to show bet number followed by bet amount and so fourth
  110.    scanf("%f", &betValue1);   
  111.    scanf("%d", &betNumber2);
  112.    scanf("%f", &betValue2);
  113.    scanf("%d", &betNumber3);
  114.    scanf("%f", &betValue3);
  115.    scanf("%d", &betNumber4);
  116.    scanf("%f", &betValue4);
  117.    
  118.    //print error message if values < 0 || > 37
  119.    
  120.    if (betNumber1 < 0 || betNumber1 > 37 || betNumber2 < 0 || betNumber2 > 37 || betNumber3 < 0 || betNumber3 > 37 || betNumber4 < 0 || betNumber4 > 37)
  121.    
  122.          {
  123.      
  124.    printf("One or more of your values isn't between 0 and 36. Please choose a number between 0 and 36: \n\n");
  125.          
  126.          }
  127.  
  128.    printf("\nYour bet number was %d \nYou placed %.2f\n\n", betNumber1, betValue1); //display user bet and user number
  129.    printf("Your bet number was %d \nYou placed %.2f\n\n", betNumber2, betValue2);
  130.    printf("Your bet number was %d \nYou placed %.2f\n\n", betNumber3, betValue3);
  131.    printf("Your bet number was %d \nYou placed %.2f\n\n", betNumber4, betValue4);
  132.    
  133.    //if betNumber equals the winning number calculate balance == betvalue * 36
  134.    
  135.    if (betNumber1 == winningNumber)
  136.      
  137.       {
  138.          printf("Congratulations, your bet matches the winning number !!! \nYour balance is %.2f \n\n", (betValue1 * 36));       
  139.       }
  140.      
  141.    if (betNumber2 == winningNumber)
  142.      
  143.       {
  144.          printf("\nCongratulations, your bet matches the winning number !!! \nYour balance is %.2f \n\n", (betValue2 * 36));         
  145.       }
  146.      
  147.    if (betNumber3 == winningNumber)
  148.      
  149.       {
  150.          printf("\nCongratulations, your bet matches the winning number !!! \nYour balance is %.2f \n\n", (betValue3 * 36));         
  151.       }
  152.      
  153.    if (betNumber4 == winningNumber)
  154.      
  155.       {
  156.          printf("\nCongratulations, your bet matches the winning number !!! \n\nYour balance is %.2f \n\n", (betValue4 * 36));         
  157.       }
  158.      
  159.    if (betNumber1 == winningNumber)
  160.      
  161.       {
  162.          printf("\nAfter 4 bets you have made %.2f \n", (totalProfit == betValue1 * 36 + betValue2 * 36 + betValue3 * 36 + betValue4));
  163.          //calculate total profit after all bets have been made
  164.       }
  165.      
  166.      
  167.    if (betNumber2 == winningNumber)
  168.      
  169.       {
  170.         printf("After 4 bets you have made %.2f \n", (totalProfit == betValue1 * 36 + betValue2 * 36 + betValue3 * 36 + betValue4));       
  171.       }
  172.      
  173.    if (betNumber3 == winningNumber)
  174.      
  175.       {
  176.         printf("After 4 bets you have made %.2f \n", (totalProfit == betValue1 * 36 + betValue2 * 36 + betValue3 * 36 + betValue4))
  177.       }
  178.      
  179.    if (betNumber4 == winningNumber)
  180.      
  181.       {
  182.         printf("After 4 bets you have made %.2f \n", (totalProfit == betValue1 * 36 + betValue2 * 36 + betValue3 * 36 + betValue4));
  183.       }
  184.        
  185.     if ((betNumber1 != winningNumber || betNumber2 != winningNumber || betNumber3 != winningNumber || betNumber4 != winningNumber))
  186.      
  187.       {
  188.          printf("For bet number 1, you lost %.2f\n", betValue1); //displays how much has been lost on each bet
  189.          printf("For bet number 2, you lost %.2f\n", betValue2);
  190.          printf("For bet number 3, you lost %.2f\n", betValue3);
  191.          printf("For bet number 4, you lost %.2f\n", betValue4);
  192.          printf("\nAfter 4 bets you have lost %.2f \n", (betValue1 + betValue2 + betValue3 + betValue4 ));   
  193.       }   
  194.    
  195.    return 0;
  196. }