<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3. INPUT
  4.    First Bet Number as Integer
  5.    First Bet Stake as Float
  6.    Second Bet Number as Integer
  7.    Second Bet Stake as Float
  8.    Third Bet Number as Integer
  9.    Third Bet Stake as Float
  10.    Fourth Bet Number as Integer
  11.    Fourth Bet Stake as Float
  12. STORE
  13.    First Winning Bet Number = 0 as Integer
  14.    Second Winning Bet Number = 0 as Integer
  15.    Third Winning Bet Number = 0 as Integer
  16.    Fourth Winning Bet Number = 0 as Integer
  17.    First Bet Payout = 0 as Float
  18.    Second Bet Payout = 0 as Float
  19.    Third Bet Payout = 0 as Float
  20.    Fourth Bet Payout = 0 as Float
  21.    Total Payout = 0 as Float
  22.    Odds = 35/1 as Integer
  23. READ
  24.    First Bet, First Stake, Second Bet, Second Stake, Third Bet, Third Stake, Fourth Bet, Fourth Stake
  25. Random Function()
  26. First Winning Bet Number = Random(38)
  27. Second Winning Bet Number = Random(38)
  28. Third Winning Bet Number = Random(38)
  29. Fourth Winning Bet Number = Random(38)
  30. PRINT
  31.    Welcome Message & Instructions
  32. IF First Bet Number < 38 & First Bet Number >= 0 THEN
  33.    IF First Bet Stake >= 1 THEN
  34.       IF First Bet Number == 37 THEN
  35.          PRINT
  36.             First bet is 00
  37.       ELSE
  38.          PRINT
  39.             First bet number
  40.       END IF
  41.       PRINT
  42.          First Winning Number
  43.       IF First Winning Bet Number == 37 THEN
  44.          PRINT
  45.             First winning number is 00
  46.       ELSE
  47.          PRINT
  48.             First winning number
  49.       END IF
  50.       IF First Bet Number == First Winning Number THEN
  51.          First Bet Payout = First Bet Stake * Odds
  52.          Total Payout = Payout Total + First Payout + First Bet Stake
  53.          PRINT
  54.             Payout of the first bet
  55.             Subtotal
  56.       ELSE
  57.          First Bet Payout = First Bet Stake
  58.          Total Payout = Total Payout - First Bet Payout
  59.          PRINT
  60.             Payout of the first bet
  61.             Subtotal
  62.       END IF
  63.    ELSE
  64.       PRINT
  65.          First bet stake is too low
  66.    END IF
  67. ELSE
  68.    First bet number is out of range
  69. END IF
  70. IF Second Bet Number < 38 & Second Bet Number >= 0 THEN
  71.    IF Second Bet Stake >= 1 THEN
  72.       IF Second Bet Number == 37 THEN
  73.          PRINT
  74.             Second bet is 00
  75.       ELSE
  76.          PRINT
  77.             Second bet number
  78.       END IF
  79.       PRINT
  80.          Second Winning Number
  81.       IF Second Winning Bet Number == 37 THEN
  82.          PRINT
  83.             Second winning number is 00
  84.       ELSE
  85.          PRINT
  86.             Second winning number
  87.       END IF
  88.       IF Second Bet Number == Second Winning Number THEN
  89.          Second Bet Payout = Second Bet Stake * Odds
  90.          Total Payout = Payout Total + Second Payout + Second Bet Stake
  91.          PRINT
  92.             Payout of the second bet
  93.             Subtotal
  94.       ELSE
  95.          Second Bet Payout = Second Bet Stake
  96.          Total Payout = Total Payout - Second Bet Payout
  97.          PRINT
  98.             Payout of the second bet
  99.             Subtotal
  100.       END IF
  101.    ELSE
  102.       PRINT
  103.          Second bet stake is too low
  104.    END IF
  105. ELSE
  106.    Second bet number is out of range
  107. END IF
  108. IF Third Bet Number < 38 & Third Bet Number >= 0 THEN
  109.    IF Third Bet Stake >= 1 THEN
  110.       IF Third Bet Number == 37 THEN
  111.          PRINT
  112.             Third bet is 00
  113.       ELSE
  114.          PRINT
  115.             Third bet number
  116.       END IF
  117.       PRINT
  118.          Third Winning Number
  119.       IF Third Winning Bet Number == 37 THEN
  120.          PRINT
  121.             Third winning number is 00
  122.       ELSE
  123.          PRINT
  124.             Third winning number
  125.       END IF
  126.       IF Third Bet Number == Third Winning Number THEN
  127.          Third Bet Payout = Third Bet Stake * Odds
  128.          Total Payout = Payout Total + Third Payout + Third Bet Stake
  129.          PRINT
  130.             Payout of the third bet
  131.             Subtotal
  132.       ELSE
  133.          Third Bet Payout = Third Bet Stake
  134.          Total Payout = Total Payout - Third Bet Payout
  135.          PRINT
  136.             Payout of the third bet
  137.             Subtotal
  138.       END IF
  139.    ELSE
  140.       PRINT
  141.          Third bet stake is too low
  142.    END IF
  143. ELSE
  144.    Third bet number is out of range
  145. END IF
  146. IF Fourth Bet Number < 38 & Fourth Bet Number >= 0 THEN
  147.    IF Fourth Bet Stake >= 1 THEN
  148.       IF Fourth Bet Number == 37 THEN
  149.          PRINT
  150.             Fourth bet is 00
  151.       ELSE
  152.          PRINT
  153.             Fourth bet number
  154.       END IF
  155.       PRINT
  156.          Fourth Winning Number
  157.       IF Fourth Winning Bet Number == 37 THEN
  158.          PRINT
  159.             Fourth winning number is 00
  160.       ELSE
  161.          PRINT
  162.             Fourth winning number
  163.       END IF
  164.       IF Fourth Bet Number == Fourth Winning Number THEN
  165.          Fourth Bet Payout = Fourth Bet Stake * Odds
  166.          Total Payout = Payout Total + Fourth Payout + Fourth Bet Stake
  167.          PRINT
  168.             Payout of the fourth bet
  169.             Subtotal
  170.       ELSE
  171.          Fourth Bet Payout = Fourth Bet Stake
  172.          Total Payout = Total Payout - Fourth Bet Payout
  173.          PRINT
  174.             Payout of the fourth bet
  175.             Subtotal
  176.       END IF
  177.    ELSE
  178.       PRINT
  179.          Fourth bet stake is too low
  180.    END IF
  181. ELSE
  182.    Fourth bet number is out of range
  183. END IF
  184. IF Total Payout > 0 THEN
  185.    PRINT
  186.       Total Winnings
  187. ELSE IF Total Payout < 0 THEN
  188.    PRINT
  189.       Total Losses
  190. ELSE
  191.    PRINT
  192.       No winnings or losses
  193. END IF
  194. */
  195.  
  196. #include <stdio.h>
  197. #include <stdlib.h>
  198. #include <time.h>
  199.  
  200. int main(void)
  201. {
  202. int betOneNumber=0; /*Declaring the Input Variables for bets and stakes */
  203. float betOneStake=0;
  204. int betTwoNumber=0;
  205. float betTwoStake=0;
  206. int betThreeNumber=0;
  207. float betThreeStake=0;
  208. int betFourNumber=0;
  209. float betFourStake=0;
  210.  
  211. int winningOne=0; /* Declaring the winning number variables to be used later in the code */
  212. int winningTwo=0;
  213. int winningThree=0;
  214. int winningFour=0;
  215.  
  216. float payoutOne=0; /* Declaring the payout variables to be used later in the code */
  217. float payoutTwo=0;
  218. float payoutThree=0;
  219. float payoutFour=0;
  220. float payoutTotal=0;
  221. int payout=35/1;
  222.  
  223. scanf("%d %f %d %f %d %f %d %f", &betOneNumber, &betOneStake, &betTwoNumber, &betTwoStake, &betThreeNumber, &betThreeStake, &betFourNumber, &betFourStake); /* Reading the inputs */
  224.  
  225. srand(time(0)); /* Resetting the random function so the next round of numbers will differ */
  226. winningOne=rand()%38; /* Using the random function to pick a number between 0-37 */
  227. winningTwo=rand()%38;
  228. winningThree=rand()%38;
  229. winningFour=rand()%38;
  230.  
  231. printf("Welcome to American Roulette. \n");
  232. printf("Please enter a bet number between 0-36 or to bet on 00 enter 37. \n"); /* Instructions */
  233. printf("======================================================================================================================== \n");
  234.  
  235. printf("> Bet One \n");
  236. if (betOneNumber < 38 && betOneNumber >= 0) /* If statement to check that the bet number is between 0-37 */
  237.    {
  238.    if(betOneStake >= 1) /* If statement to check that the bet stake is at least 1.00 */
  239.    {
  240.       if (betOneNumber == 37) /* If statement whether the bet number is equal to 37 */
  241.          {
  242.          printf("Your first bet number is 00 \n"); /* Prints 37 as 00, as the input 00 has the same binary value as 0. So they are the same number */
  243.          }
  244.       else
  245.          {
  246.          printf("Your first bet number is %d \n", betOneNumber); /* Else case to print the bet number entered */
  247.          }
  248.       printf("Your bet is %.2f \n", betOneStake); /* Prints the stake entered of the current bet */
  249.       if (winningOne == 37) /* If statement whether the bet number is equal to 37 */
  250.          {
  251.          printf("The first winning bet number is 00 \n"); /* Prints 37 as 00, as the input 00 has the same binary value as 0. So they are the same number */
  252.          }
  253.       else
  254.          {
  255.          printf("The first winning bet number is %d \n", winningOne); /* Else case to print the winning bet number */
  256.          }
  257.       if (betOneNumber == winningOne) /*If statement to check if the bet number is equal to the winning bet number */
  258.          {
  259.          payoutOne=(betOneStake*payout); /* Multiplies the stake entered with the odds and assigns it to the variable */
  260.          payoutTotal=(payoutTotal+payoutOne+betOneStake); /* Adds the previous subtotal, current bet payout and the current bet stake */
  261.          printf("WIN! Your payout for your first bet is %.2f \n", payoutOne+betOneStake); /* Prints how much the bet won the user */
  262.          printf("Your subtotal is %.2f \n", payoutTotal); /* Prints the subtotal of the bets so far */
  263.          printf("------------------------------------------------------------------------------------------------------------------------ \n");
  264.          }
  265.       else
  266.          {
  267.          payoutOne=(betOneStake); /* Assigns the stake entered to the variable */
  268.          payoutTotal=(payoutTotal-payoutOne); /* Takes away the payout variable from the subtotal and assigns it to the subtotal variable */
  269.          printf("LOSS! For your first bet, you have a loss of -%.2f \n", payoutOne); /* Prints how much the bet lost the user */
  270.          printf("Your subtotal is %.2f \n", payoutTotal); /* Prints the subtotal of the bets so far */
  271.          printf("------------------------------------------------------------------------------------------------------------------------ \n");
  272.          }
  273.          }
  274.    else
  275.       {
  276.       printf("The first bet stake entered is too low, please enter a stake of at least 1.00 \n"); /* Else case if the stake is too low, print error message */
  277.       printf("------------------------------------------------------------------------------------------------------------------------ \n");
  278.       }
  279.       }
  280. else
  281.    {
  282.    printf("The first bet number entered is out of range, please try again within the range of 0-36, or enter 37 to place a bet on 00. \n"); /* Else case if the bet is out of range, print error message */
  283.    printf("------------------------------------------------------------------------------------------------------------------------ \n");
  284.    }
  285.    
  286. printf("> Bet Two \n");
  287. if (betTwoNumber < 38 && betTwoNumber >= 0)
  288.    {
  289.    if(betTwoStake >= 1)
  290.    {
  291.       if (betTwoNumber == 37)
  292.          {
  293.          printf("Your second bet number is 00 \n");
  294.          }
  295.       else
  296.          {
  297.          printf("Your second bet number is %d \n", betTwoNumber);
  298.          }
  299.       printf("Your bet is %.2f \n", betTwoStake);
  300.       if (winningTwo == 37)
  301.          {
  302.          printf("The second winning bet number is 00 \n");
  303.          }
  304.       else
  305.          {
  306.          printf("The second winning bet number is %d \n", winningTwo);
  307.          }
  308.       if (betTwoNumber == winningTwo)
  309.          {
  310.          payoutTwo=(betTwoStake*payout);
  311.          payoutTotal=(payoutTotal+payoutTwo+betTwoStake);
  312.          printf("WIN! Your payout for your second bet is %.2f \n", payoutTwo+betTwoStake);
  313.          printf("Your subtotal is %.2f \n", payoutTotal);
  314.          printf("------------------------------------------------------------------------------------------------------------------------ \n");
  315.          }
  316.       else
  317.          {
  318.          payoutTwo=(betTwoStake);
  319.          payoutTotal=(payoutTotal-payoutTwo);
  320.          printf("LOSS! For your second bet, you have a loss of -%.2f \n", payoutTwo);
  321.          printf("Your subtotal is %.2f \n", payoutTotal);
  322.          printf("------------------------------------------------------------------------------------------------------------------------ \n");
  323.          }
  324.          }
  325.    else
  326.       {
  327.       printf("The second bet stake entered is too low, please enter a stake of at least 1.00 \n");
  328.       printf("------------------------------------------------------------------------------------------------------------------------ \n");
  329.       }
  330.       }
  331. else
  332.    {
  333.    printf("The second bet number entered is out of range, please try again within the range of 0-36, or enter 37 to place a bet on 00. \n");
  334.    printf("------------------------------------------------------------------------------------------------------------------------ \n");
  335.    }
  336.  
  337. printf("> Bet Three \n");
  338. if (betThreeNumber < 38 && betThreeNumber >= 0)
  339.    {
  340.    if(betThreeStake >= 1)
  341.    {
  342.       if (betThreeNumber == 37)
  343.          {
  344.          printf("Your third bet number is 00 \n");
  345.          }
  346.       else
  347.          {
  348.          printf("Your third bet number is %d \n", betThreeNumber);
  349.          }
  350.       printf("Your bet is %.2f \n", betThreeStake);
  351.       if (winningThree == 37)
  352.          {
  353.          printf("The third winning bet number is 00 \n");
  354.          }
  355.       else
  356.          {
  357.          printf("The third winning bet number is %d \n", winningThree);
  358.          }
  359.       if (betThreeNumber == winningThree)
  360.          {
  361.          payoutThree=(betThreeStake*payout);
  362.          payoutTotal=(payoutTotal+payoutThree+betThreeStake);
  363.          printf("WIN! Your payout for your third bet is %.2f \n", payoutThree+betThreeStake);
  364.          printf("Your subtotal is %.2f \n", payoutTotal);
  365.          printf("------------------------------------------------------------------------------------------------------------------------ \n");
  366.          }
  367.       else
  368.          {
  369.          payoutThree=(betThreeStake);
  370.          payoutTotal=(payoutTotal-payoutThree);
  371.          printf("LOSS! For your third bet, you have a loss of -%.2f \n", payoutThree);
  372.          printf("Your subtotal is %.2f \n", payoutTotal);
  373.          printf("------------------------------------------------------------------------------------------------------------------------ \n");
  374.          }
  375.          }
  376.    else
  377.       {
  378.       printf("The third bet stake entered is too low, please enter a stake of at least 1.00 \n");
  379.       printf("------------------------------------------------------------------------------------------------------------------------ \n");
  380.       }
  381.       }
  382. else
  383.    {
  384.    printf("The third bet number entered is out of range, please try again within the range of 0-36, or enter 37 to place a bet on 00. \n");
  385.    printf("------------------------------------------------------------------------------------------------------------------------ \n");
  386.    }
  387.  
  388. printf("> Bet Four \n");
  389. if (betFourNumber < 38 && betFourNumber >= 0)
  390.    {
  391.    if(betFourStake >= 1)
  392.    {
  393.       if (betFourNumber == 37)
  394.          {
  395.          printf("Your fourth bet number is 00 \n");
  396.          }
  397.       else
  398.          {
  399.          printf("Your fourth bet number is %d \n", betFourNumber);
  400.          }
  401.       printf("Your bet is %.2f \n", betFourStake);
  402.       if (winningFour == 37)
  403.          {
  404.          printf("The fourth winning bet number is 00 \n");
  405.          }
  406.       else
  407.          {
  408.          printf("The fourth winning bet number is %d \n", winningFour);
  409.          }
  410.       if (betFourNumber == winningFour)
  411.          {
  412.          payoutFour=(betFourStake*payout);
  413.          payoutTotal=(payoutTotal+payoutFour+betFourStake);
  414.          printf("WIN! Your payout for your fourth bet is %.2f \n", payoutFour+betFourStake);
  415.          printf("Your subtotal is %.2f \n", payoutTotal);
  416.          printf("------------------------------------------------------------------------------------------------------------------------ \n");
  417.          }
  418.       else
  419.          {
  420.          payoutFour=(betFourStake);
  421.          payoutTotal=(payoutTotal-payoutFour);
  422.          printf("LOSS! For your fourth bet, you have a loss of -%.2f \n", payoutFour);
  423.          printf("Your subtotal is %.2f \n", payoutTotal);
  424.          printf("------------------------------------------------------------------------------------------------------------------------ \n");
  425.          }
  426.          }
  427.    else
  428.       {
  429.       printf("The fourth bet stake entered is too low, please enter a stake of at least 1.00 \n");
  430.       printf("------------------------------------------------------------------------------------------------------------------------ \n");
  431.       }
  432.       }
  433. else
  434.    {
  435.    printf("The fourth bet number entered is out of range, please try again within the range of 0-36, or enter 37 to place a bet on 00. \n");
  436.    printf("------------------------------------------------------------------------------------------------------------------------ \n");
  437.    }
  438.  
  439. if (payoutTotal > 0) /* If statement to check that the subtotal is greater than 0 */
  440.    {
  441.    printf("Your total winnings today is %.2f \n", payoutTotal); /* Prints the total winnings */
  442.    }
  443. else if (payoutTotal < 0) /* If statement to check that the subtotal is less than 0 */
  444.    {
  445.    printf("Your total loss today is %.2f \n", payoutTotal); /* Prints the total losses */
  446.    }
  447. else
  448.    {
  449.    printf("Sorry, you have not made a profit or a loss \n"); /* Else case, prints no profit or loss was made */
  450.    }
  451. printf("Thank You for playing American Roulette");
  452. }