<mosaic.cnfolio.com>
PROGRAM
  1. #include <stdio.h>#include <stdlib.h>
  2. #include <time.h>
  3. /*
  4. START
  5. SET number of bets to zero
  6. while number of bets is less then 4
  7. get bet number and bet value
  8. Spin wheel using table with ppockets for 0 to 36
  9. Display bet number
  10. Display bet amount
  11. Display winning number
  12. If bet number equals winning number
  13. Then
  14.     Add bet value to wallet value
  15.     Add bet value multiplied by 35
  16.     Display value multiplied by 35
  17. else subtract bet from wallet value
  18.       Display zero as payout value
  19. END if
  20. Display wallet value
  21.   Increase number of bets by one
  22. END while
  23. Display final wallet value
  24. END
  25. */
  26.  int main(void)
  27. {
  28. //Variables   
  29.   int betmode;   
  30.   int straightbet, cashbet, parity;
  31.   int number;
  32.   int balance;
  33.   char colorbet, R, B;
  34.  
  35. //Instructions for game
  36.    printf("\nEntering the casino, you have $100\n");
  37.    printf("There are 3 types of bets you can make\n\n");
  38.    printf("1) Straight-up bet: Choose a single number. High risk, high payout! (35 to 1)\n\n");
  39.    printf("2) Red or black: Choose a color.(1 to 1)\n Red numbers are  1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36\n Black numbers are 2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35\n\n");
  40.    printf("3) Odd or even: Choose odd or even (1 to 1)");
  41.  
  42.  
  43.   //Select game mode
  44.   printf("\nPlease select your preferred type of bet. Enter 1, 2, or 3> ");
  45.   scanf("%d", &betmode);
  46.   balance=100;
  47.   //Loop to keep game going as long as you have cash
  48. while (balance>0)
  49.  
  50.   if (betmode==1)
  51.   printf("\nSettling for the big money, ey?\nEnter number between 1 to 36 you'd like to bet on> ");
  52.   scanf("%d", &straightbet);
  53.   printf("Now how much money are you willing to take the risk for? Payout is 35 to 1: ");
  54.   scanf("%d", &cashbet);
  55.   printf("\nYou have bet %d on the numbers %d, good luck here are the results:\n", cashbet, straightbet);
  56.  
  57.   //Spin Roulette
  58.     if (number==straightbet)
  59.                   {balance += (cashbet*35);
  60.                    printf("Winner Winner! You now have $%d in your pocket", balance);}
  61.                 else
  62.                    balance -= cashbet;
  63.                    printf("Sorry. You've lost $%d. Your new balance is $%d", cashbet, balance);
  64.       }
  65.        else if (betmode==2)         //Red or black bets
  66.           {
  67.            printf("\nAlright pick a color. Choose R for RED or B for BLACK> ");
  68.            scanf("&c", &colorbet);
  69.            printf("\nNow how much money are you willing to risk? Payout is 1 to 1> ");
  70.            scanf("%d", &cashbet);
  71.            printf("\nYou have bet $%d on the color %c", cashbet, colorbet);
  72.            printf("\nPress ENTER to spin the roulette. Keep your fingers crossed!");
  73.            getchar();
  74.            getchar();
  75.            spin_roulette();
  76.                 if (colorbet==R)
  77.                     {
  78.                     if (number==red[17])
  79.                       {balance += cashbet;
  80.                        printf("Winner Winner! You now have $%d in your pocket", balance);}
  81.                     else
  82.                        balance -= cashbet;
  83.                        printf("Sorry. You've lost $%d. Your new balance is $%d", cashbet, balance);
  84.                     }                   
  85.                 else if (colorbet==B)
  86.                     {
  87.                     if (number==black[17])
  88.                        balance += cashbet;
  89.                        printf("Winner Winner! You now have $%d in your pocket", balance);}
  90.                     else
  91.                        balance -= cashbet;
  92.                        printf("Sorry. You've lost $%d. Your new balance is $%d", cashbet, balance);   
  93.                     }
  94.      else           //Odd or even bets
  95.          {  printf("Alright enter 1 for odd or 2 for even. Choose wisely!> ");
  96.             scanf("%d", &parity);
  97.             printf("\nNow how much money are you willing to risk? Payout is 1 to 1> ");
  98.             scanf("%d", &cashbet);
  99.                   if (parity==1)
  100.                      printf("\nYou have bet $%d on odds", cashbet);
  101.                   else
  102.                       printf("\nYou have bet $%d on evens", cashbet);
  103.             printf("\nPress ENTER to spin the roulette. Keep your fingers crossed!");
  104.             getchar();
  105.             getchar();
  106.             spin_roulette();
  107.                    if (parity==1)
  108.                       {
  109.                         if (number%2==1)
  110.                           {balance += cashbet;
  111.                            printf("Winner Winner! You now have $%d in your pocket", balance);}
  112.                         else
  113.                            balance -= cashbet;
  114.                            printf("Sorry. You've lost $%d. Your new balance is $%d", cashbet, balance);
  115.                         }
  116.                    else
  117.                          if (number%2==0)
  118.                           {balance += cashbet;
  119.                            printf("Winner Winner! You now have $%d in your pocket", balance);}
  120.                         else
  121.                            balance -= cashbet;
  122.                            printf("Sorry. You've lost $%d. Your new balance is $%d", cashbet, balance);
  123.                            }
  124.                                
  125. }
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132. getchar();
  133. getchar();
  134. return (0);
  135. }
  136.  
  137.  
  138. void print_title(void)
  139. {
  140.     printf("       \n");
  141.     printf("*******  ******   *      *  *      ****** ******* *******  ******        \n");
  142.     printf("*     * *      *  *      *  *      *         *       *     *        \n");
  143.     printf("******* *      *  *      *  *      *         *       *     *        \n");
  144.     printf("*   *   *      *  *      *  *      ****      *       *     ****        \n");
  145.     printf("*    *  *      *  *      *  *      *         *       *     *        \n");
  146.     printf("*     *  ******    ******   ****** ******    *       *     ******        ");
  147.     printf("                           ");
  148. }
  149.  
  150.  
  151. int spin_roulette (void)
  152. {
  153.     int number;
  154.     srand(time(NULL));
  155.     number=1+(rand()%36);
  156.     printf("The ball has landed on %d\n", number);
  157.     return number;
  158. }