<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. Start
  3.    Read the inputted number bet on and amount bet
  4.    IF any of the numbers bet on are less than 2 digits long
  5.       THEN
  6.          Display an error message
  7.    END IF
  8.    IF any of the numbers bet on are longer than 2 digits
  9.       THEN
  10.          Display an error message
  11.    END IF
  12.    IF any of the amounts bet on are equal to 0
  13.       THEN
  14.          Display an error message
  15.    END IF
  16.    If any of the amounts bet on are less than 0
  17.       THEN
  18.          Display an error message
  19.    ELSE
  20.       IF the first number bet on is equal to 00
  21.          THEN
  22.             Set the number to 37
  23.       Else
  24.          THEN
  25.             Convert the number bet on
  26.       END IF
  27.       IF the second number bet on is equal to 00
  28.          THEN
  29.             Set the number to 37
  30.       Else
  31.          THEN
  32.             Convert the number bet on
  33.       END IF
  34.       IF the third number bet on is equal to 00
  35.          THEN
  36.             Set the number to 37
  37.       Else
  38.          THEN
  39.             Convert the number bet on
  40.       END IF
  41.       IF the fourth number bet on is equal to 00
  42.          THEN
  43.             Set the number to 37
  44.       Else
  45.          THEN
  46.             Convert the number bet on
  47.       END IF
  48.       Get a random number between 0 and 37 for bet 1
  49.       Get a random number between 0 and 37 for bet 2
  50.       Get a random number between 0 and 37 for bet 3
  51.       Get a random number between 0 and 37 for bet 4
  52.       IF the random number for bet 1 is equal to the number bet on
  53.          THEN
  54.             Set the winnings to 36 times what was originally bet
  55.             Display the details of the first bet
  56.       Else
  57.          THEN
  58.             Subtract the first amount bet from the winnings
  59.             Display the details of the first bet
  60.       END IF
  61.       IF  the random number for bet 2 is equal to the number bet on
  62.          THEN
  63.             Set the winnings to 36 times what was originally bet
  64.             Display the details of the second bet
  65.       Else
  66.          THEN
  67.             Subtract the second amount bet from the winnings
  68.             Display the details of the second bet
  69.       END IF
  70.       IF  the random number for bet 3 is equal to the number bet on
  71.          THEN
  72.             Set the winnings to 36 times what was originally bet
  73.             Display the details of the third bet
  74.       Else
  75.          THEN
  76.             Subtract the second amount bet from the winnings
  77.             Display the details of the third bet
  78.       END IF
  79.       IF  the random number for bet 4 is equal to the number bet on
  80.          THEN
  81.             Set the winnings to 36 times what was originally bet
  82.             Display the details of the fourth bet
  83.       Else
  84.          THEN
  85.             Subtract the second amount bet from the winnings
  86.             Display the details of the fourth bet
  87.       END IF
  88.    End If
  89.    Set the total winnings to the sum of each individual bet
  90.    Display the details of all four bets
  91. END
  92. */         
  93. #include <stdio.h>
  94. #include <stdlib.h>
  95. #include <time.h>
  96. #include <string.h>
  97.  
  98. int spin(int);
  99.  
  100. int main()
  101. {
  102.    int Random1 = 0, Random2 = 0, Random3 = 0, Random4 = 0;
  103.    char DoubleZero[] = "00"; /*For coparing later on*/
  104.    int CompareBet1 = 0, CompareBet2 = 0, CompareBet3 = 0, CompareBet4 = 0;
  105.    char NumberBetOn1[2] = {'\0'}, NumberBetOn2[2] = {'\0'}, NumberBetOn3[2] = {'\0'}, NumberBetOn4[2] = {'\0'};
  106.    double AmountBet1 = 0, AmountBet2 = 0, AmountBet3 = 0, AmountBet4 = 0;
  107.    double WinningsBet1 = 0, WinningsBet2 = 0, WinningsBet3 = 0, WinningsBet4 = 0, TotalWinnings = 0;
  108.    srand(time(0));
  109.    scanf("%s %lf %s %lf %s %lf %s %lf", &NumberBetOn1, &AmountBet1, &NumberBetOn2, &AmountBet2, &NumberBetOn3, &AmountBet3, &NumberBetOn4, &AmountBet4);
  110.    if ((strlen(NumberBetOn1) == 0) || (strlen(NumberBetOn2) == 0) || (strlen(NumberBetOn3) == 0) || (strlen(NumberBetOn4) == 0))
  111.       {
  112.          printf("Please make sure to enter 4 numbers you would like to bet on. \n");
  113.       }
  114.    if ((strlen(NumberBetOn1) > 2) || (strlen(NumberBetOn2) > 2) || (strlen(NumberBetOn3) > 2) || (strlen(NumberBetOn4) > 2))
  115.       {
  116.          printf("Please make sure to enter a valid number to bet on.\n");
  117.       }
  118.    if ((AmountBet1 == 0) || (AmountBet2 == 0) || (AmountBet3 == 0) || (AmountBet4 == 0))
  119.       {
  120.          printf("Please make sure to enter the amount you would like to bet. \n");
  121.       }
  122.    if ((AmountBet1 < 0) || (AmountBet2 < 0) || (AmountBet3 < 0) || (AmountBet4 < 0))
  123.       {
  124.          printf("Please make sure to enter a valid number to bet on. \n")
  125.       }
  126.    else
  127.       {
  128.         if (strcmp(NumberBetOn1, DoubleZero) == 0)
  129.            {
  130.               CompareBet1 = 37;
  131.            }
  132.         else
  133.            {
  134.               CompareBet1 = atoi(NumberBetOn1);
  135.            }
  136.         if (strcmp(NumberBetOn2, DoubleZero) == 0)
  137.            {
  138.               CompareBet2 = 37;
  139.            }
  140.         else
  141.            {
  142.               CompareBet2 = atoi(NumberBetOn2);
  143.            }
  144.         if (strcmp(NumberBetOn3, DoubleZero) == 0)
  145.            {
  146.               CompareBet3 = 37;
  147.            }
  148.         else
  149.            {
  150.               CompareBet3 = atoi(NumberBetOn3);
  151.            }
  152.         if (strcmp(NumberBetOn4, DoubleZero) == 0)
  153.            {
  154.               CompareBet4 = 37;
  155.            }
  156.         else
  157.            {
  158.               CompareBet4 = atoi(NumberBetOn4);
  159.            }
  160.         Random1 = spin(Random1);
  161.         Random2 = spin(Random2);
  162.         Random3 = spin(Random3);
  163.         Random4 = spin(Random4);
  164.         if (Random1 == CompareBet1)
  165.            {
  166.               WinningsBet1 = 36 * AmountBet1;
  167.               printf("Your first bet:\nThe number you bet on: %s\nThe amount you bet: %.2lf\nThe winning number: %d\nPayout Value: 35:1\nYour winnings: %.2lf\n", NumberBetOn1, AmountBet1, Random1, WinningsBet1);
  168.            }
  169.         else
  170.            {
  171.               WinningsBet1 -= AmountBet1;
  172.               printf("Your first bet:\nThe number you bet on: %s\nThe amount you bet: %.2lf\nThe winning number: %d\nPayout Value: 35:1\nYour winnings: %.2lf\n", NumberBetOn1, AmountBet1, Random1, WinningsBet1);
  173.            }
  174.         if (Random2 == CompareBet2)
  175.            {
  176.               WinningsBet2 = 36 * AmountBet2;
  177.               printf("Your second bet:\nThe number you bet on: %s\nThe amount you bet: %.2lf\nThe winning number: %d\nPayout Value: 35:1\nYour winnings: %.2lf\n", NumberBetOn2, AmountBet2, Random2, WinningsBet2);
  178.            }
  179.         else
  180.            {
  181.               WinningsBet2 -= AmountBet2;
  182.               printf("Your second bet:\nThe number you bet on: %s\nThe amount you bet: %.2lf\nThe winning number: %d\nPayout Value: 35:1\nYour winnings: %.2lf\n", NumberBetOn2, AmountBet2, Random2, WinningsBet2);
  183.            }
  184.         if (Random3 == CompareBet3)
  185.            {
  186.               WinningsBet3 = 36 * AmountBet3;
  187.               printf("Your third bet:\nThe number you bet on: %s\nThe amount you bet: %.2lf\nThe winning number: %d\nPayout Value: 35:1\nYour winnings: %.2lf\n", NumberBetOn3, AmountBet3, Random3, WinningsBet3);
  188.            }
  189.         else
  190.            {
  191.               WinningsBet3 -= AmountBet3;
  192.               printf("Your third bet:\nThe number you bet on: %s\nThe amount you bet: %.2lf\nThe winning number: %d\nPayout Value: 35:1\nYour winnings: %.2lf\n", NumberBetOn3, AmountBet3, Random3, WinningsBet3);
  193.            }
  194.         if (Random4 == CompareBet4)
  195.            {
  196.               WinningsBet4 = 36 * AmountBet4;
  197.               printf("Your fourth bet:\nThe number you bet on: %s\nThe amount you bet: %.2lf\nThe winning number: %d\nPayout Value: 35:1\nYour winnings: %.2lf\n", NumberBetOn4, AmountBet4, Random4, WinningsBet4);
  198.            }
  199.         else
  200.            {
  201.               WinningsBet3 -= AmountBet3;
  202.               printf("Your fourth bet:\nThe number you bet on: %s\nThe amount you bet: %.2lf\nThe winning number: %d\nPayout Value: 35:1\nYour winnings: %.2lf\n", NumberBetOn4, AmountBet4, Random4, WinningsBet4);
  203.            }
  204.         TotalWinnings = WinningsBet1 + WinningsBet2 + WinningsBet3 + WinningsBet4;
  205.         printf("Overall you won: %.2lf", TotalWinnings);
  206.       }
  207. }
  208.  
  209. int spin(Number)
  210. {
  211.    Number = rand() % 38;
  212.    return Number;
  213. }