<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3.    GET bet number
  4.       IF bet number > 1 and < 38
  5.          Continue to bet amount
  6.          ELSE
  7.             Bet number error
  8.          IF bet amount > 0
  9.             Continue to win/lose statements
  10.             ELSE
  11.                Bet amount error
  12.             IF Bet number is not equal to random number
  13.                Display loss statement and total balance
  14.                Else
  15.                   Display win statement and total balance
  16.             END IF
  17.          END IF
  18.       END IF
  19.    END IF                               
  20. END
  21. */
  22.  
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <time.h>
  26.  
  27. int main( void )
  28. {
  29.    int number;
  30.    int bet_number [ 4 ] = { 0 };
  31.    float bet_amount [ 4 ] = { 0 };
  32.    float win_total;
  33.    
  34.    srand( time( 0 ) );
  35.    
  36.    scanf ("%d %f %d %f %d %f %d %f", &bet_number[0], &bet_amount[0],
  37.                                      &bet_number[1], &bet_amount[1],
  38.                                      &bet_number[2], &bet_amount[2],
  39.                                      &bet_number[3], &bet_amount[3]);
  40.    
  41.    if (bet_number[0] >= 1 && bet_number[0] <= 38 &&
  42.        bet_number[1] >= 1 && bet_number[1] <= 38 &&
  43.        bet_number[2] >= 1 && bet_number[2] <= 38 &&
  44.        bet_number[3] >= 1 && bet_number[3] <= 38)
  45.    {
  46.       if (bet_amount[0] > 0 &&
  47.           bet_amount[1] > 0 &&
  48.           bet_amount[2] > 0 &&
  49.           bet_amount[3] > 0)
  50.       {
  51.    
  52.        int counter;
  53.        float balance = 0;
  54.        
  55.        for ( counter = 0; counter < 4; counter++ )
  56.        
  57.        {
  58.      
  59.          number = rand() % 38; /* 37 = 0, 38 = 00 */
  60.          number++;
  61.            
  62.          printf( "You placed $%.2f on the number %d \nThe winning number was %d", bet_amount[counter], bet_number[counter], number);
  63.              
  64.          if (bet_number[counter] != number)
  65.          {
  66.             printf ("\nUnlucky, you did not win this time \nYou lost $%.2f", bet_amount[counter]);
  67.             balance -= bet_amount[counter];
  68.          }
  69.          else
  70.          {
  71.             win_total = bet_amount[counter] * 35;
  72.             printf ("\nCongratualtions you have won! \nYour total bet winnings is $%.2f", win_total);
  73.             balance += win_total;
  74.          }
  75.          printf ( "\nYour balance is now $%.2f\n", balance );
  76.          printf ( "-------------------------\n");
  77.          
  78.        }
  79.       }
  80.       else
  81.       {
  82.          printf("You must input a bet above $0");
  83.       }
  84.    }
  85.    else
  86.    {
  87.       printf("You must input bet numbers must be between 1 and 38 (37 = 0, 38 = 00)");
  88.    }
  89.    
  90. }