<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3. Get Value of BetNumber1
  4. Get Value of BetAmount1
  5. Set PayOut1 to Zero
  6.  
  7. Get Value of BetNumber2
  8. Get Value of BetAmount2
  9. Set PayOut2 to Zero
  10.  
  11. Get Value of BetNumber3
  12. Get Value of BetAmount3
  13. Set PayOut3 to Zero
  14.  
  15. Get Value of BetNumber4
  16. Get Value of BetAmount4
  17. Set PayOut4 to Zero
  18.  
  19. Pick a number between 0 and 38
  20.  
  21. IF chosen number is 38
  22.    THEN
  23.       Display "00"
  24.      
  25.    ELSE
  26.       Display the chosen number
  27. END IF
  28.  
  29.  
  30. IF BetNumber1 is less than zero
  31.    THEN
  32.       Display error message "ERROR - Choose a Bet of 0 above"
  33. END IF
  34.  
  35. IF BetNumber1 is equal or more than 39
  36.    THEN
  37.       Display error message "Choose A Number Below 39"
  38. END IF
  39.  
  40.  
  41. IF BetAmount1 equal or less than zero
  42.    THEN
  43.       Display error message "Choose A Bet Amount above zero"
  44. END IF
  45.  
  46.  
  47. IF chosen number is equal to BetNumber1
  48.    THEN
  49.       Display Text "Congratulations your number is the winning number"
  50.      
  51.       IF BetNumber1 is less than zero
  52.          THEN
  53.       Display error message "ERROR - Choose a Bet of 0 above"
  54.    END IF
  55.      
  56.       IF BetNumber1 is equal to 38
  57.          THEN
  58.             Display "00"
  59.          
  60.          ELSE
  61.             Display BetNumber1
  62.       END IF     
  63.      
  64.       Display BetAmount1
  65.       Calculate PayOut1 by multiplying BetAmount1 by 35 then add BetAmount1
  66.       Display PayOut1
  67.       Display profit by subtracting BetAmount1 from PayOut1
  68.    
  69.    ELSE
  70.       Display the RouletteNumber
  71.       Display a message telling the user they have not won
  72.      
  73.       IF BetNumber1 is less than zero
  74.          THEN
  75.             Display error message "ERROR - Choose a Bet of 0 above"
  76.       END IF
  77.      
  78.       IF BetNumber1 is equal to 38
  79.          THEN
  80.             Display "00"
  81.          
  82.          ELSE
  83.             Display BetNumber1
  84.       END IF
  85.      
  86.       Display BetAmount1
  87.       Set PayOut1 to zero
  88.       Display PayOut1
  89.       Display loss as a negative value
  90. END IF
  91.  
  92.  
  93. IF BetNumber2 is less than zero
  94.    THEN
  95.       Display error message "ERROR - Choose a Bet of 0 above"
  96. END IF
  97.  
  98. IF BetNumber2 is equal or more than 39
  99.    THEN
  100.       Display error message "Choose A Number Below 39"
  101. END IF
  102.  
  103.  
  104. IF BetAmount2 equal or less than zero
  105.    THEN
  106.       Display error message "Choose A Bet Amount above zero"
  107. END IF
  108.  
  109. IF chosen number is equal to BetNumber2
  110.    THEN
  111.       Display Text "Congratulations your number is the winning number"
  112.      
  113.       IF BetNumber2 is less than zero
  114.          THEN
  115.             Display error message "ERROR - Choose a Bet of 0 above"
  116.       END IF
  117.      
  118.       IF BetNumber2 is equal to 38
  119.          THEN
  120.             Display "00"
  121.          
  122.          ELSE
  123.             Display BetNumber2
  124.       END IF
  125.      
  126.       Display BetAmount2
  127.       Calculate PayOut2 by multiplying BetAmount2 by 35 then add BetAmount2
  128.       Display PayOut2
  129.       Display profit by subtracting BetAmount2 from PayOut2
  130.    
  131.    ELSE
  132.       Display the RouletteNumber
  133.       Display a message telling the user they have not won
  134.      
  135.       IF BetNumber2 is less than zero
  136.          THEN
  137.             Display error message "ERROR - Choose a Bet of 0 above"
  138.       END IF
  139.      
  140.       IF BetNumber2 is equal to 38
  141.          THEN
  142.             Display "00"
  143.          
  144.          ELSE
  145.             Display BetNumber2
  146.       END IF
  147.      
  148.       Display BetAmount2
  149.       Set PayOut2 to zero
  150.       Display PayOut2
  151.       Display loss as a negative value
  152. END IF
  153.  
  154. IF BetNumber3 is less than zero
  155.    THEN
  156.       Display error message "ERROR - Choose a Bet of 0 above"
  157. END IF
  158.  
  159. IF BetNumber3 is equal or more than 39
  160.    THEN
  161.       Display error message "Choose A Number Below 39"
  162. END IF
  163.  
  164.  
  165. IF BetAmount3 equal or less than zero
  166.    THEN
  167.       Display error message "Choose A Bet Amount above zero"
  168. END IF
  169.  
  170.  
  171. IF chosen number is equal to BetNumber3
  172.    THEN
  173.       Display Text "Congratulations your number is the winning number"
  174.      
  175.       IF BetNumber3 is less than zero
  176.          THEN
  177.             Display error message "ERROR - Choose a Bet of 0 above"
  178.       END IF
  179.      
  180.        IF BetNumber3 is equal to 38
  181.          THEN
  182.             Display "00"
  183.          
  184.          ELSE
  185.             Display BetNumber3
  186.       END IF
  187.      
  188.       Display BetAmount3
  189.       Calculate PayOut3 by multiplying BetAmount3 by 35 then add BetAmount3
  190.       Display PayOut3
  191.       Display profit by subtracting BetAmount3 from PayOut3
  192.    
  193.    ELSE
  194.       Display the RouletteNumber
  195.       Display a message telling the user they have not won
  196.      
  197.       IF BetNumber3 is less than zero
  198.          THEN
  199.             Display error message "ERROR - Choose a Bet of 0 above"
  200.       END IF
  201.      
  202.        IF BetNumber3 is equal to 38
  203.          THEN
  204.             Display "00"
  205.          
  206.          ELSE
  207.             Display BetNumber3
  208.       END IF
  209.      
  210.       Display BetAmount3
  211.       Set PayOut3 to zero
  212.       Display PayOut3
  213.       Display loss as a negative value
  214.      
  215. END IF
  216.  
  217.  
  218. IF BetNumber4 is less than zero
  219.    THEN
  220.       Display error message "ERROR - Choose a Bet of 0 above"
  221. END IF
  222.  
  223. IF BetNumber4 is equal or more than 39
  224.    THEN
  225.       Display error message "Choose A Number Below 39"
  226. END IF
  227.  
  228.  
  229. IF BetAmount4 equal or less than zero
  230.    THEN
  231.       Display error message "Choose A Bet Amount above zero"
  232.  
  233.  
  234. IF chosen number is equal to BetNumber4
  235.    THEN
  236.       Display Text "Congratulations your number is the winning number"
  237.      
  238.       IF BetNumber4 is less than zero
  239.          THEN
  240.             Display error message "ERROR - Choose a Bet of 0 above"
  241.       END IF
  242.      
  243.       IF BetNumber4 is equal to 38
  244.          THEN
  245.             Display "00"
  246.          
  247.          ELSE
  248.             Display BetNumber4
  249.       END IF
  250.      
  251.       Display BetAmount4
  252.       Calculate PayOut4 by multiplying BetAmount4 by 35 then add BetAmount4
  253.       Display PayOut4
  254.       Display profit by subtracting BetAmount4 from PayOut4
  255.    
  256.    ELSE
  257.       Display the RouletteNumber
  258.       Display a message telling the user they have not won
  259.      
  260.       IF BetNumber4 is less than zero
  261.          THEN
  262.             Display error message "ERROR - Choose a Bet of 0 above"
  263.       END IF
  264.      
  265.      IF BetNumber4 is equal to 38
  266.          THEN
  267.             Display "00"
  268.          
  269.          ELSE
  270.             Display BetNumber4
  271.       END IF
  272.      
  273.       BetAmount4
  274.       Set PayOut4 to zero
  275.       Display PayOut4
  276.       Display loss as a negative value
  277.      
  278. END IF
  279.  
  280. Calculate Total BetAmount by adding all BetAmounts together
  281. Calculate Total PayOut by adding all PayOut values together
  282. Calculate Total Profit or Loss by subtracting TotalPayOut from TotalBetAmount
  283.  
  284. IF the total is a more than TotalBetAmounts
  285.    THEN
  286.       Display message "You Have Made A Profit"
  287.    
  288.    ELSE
  289.       Display message "You Have Made A Loss"
  290. END IF
  291.  
  292. END
  293.  
  294. */
  295.  
  296. #include <stdio.h>
  297. #include <stdlib.h>
  298. #include <time.h>
  299.  
  300. int main (void)
  301. {
  302.  
  303. int BetNumber1 = -1;
  304. double BetAmount1;
  305. double PayOut1 = 0;
  306.  
  307. int BetNumber2 = -1;
  308. double BetAmount2;
  309. double PayOut2 = 0;
  310.  
  311. int BetNumber3 = -1 ;
  312. double BetAmount3;
  313. double PayOut3 = 0;
  314.  
  315. int BetNumber4 = -1;
  316. double BetAmount4;
  317. double PayOut4 = 0;
  318.  
  319. int RouletteNumber;
  320. double TotalBetAmount;
  321. double TotalPayOut;
  322. double TotalProfitorLoss;
  323.  
  324. scanf ("%d", &BetNumber1); scanf ("%lf", &BetAmount1);
  325. scanf ("%d", &BetNumber2); scanf ("%lf", &BetAmount2);
  326. scanf ("%d", &BetNumber3); scanf ("%lf", &BetAmount3);
  327. scanf ("%d", &BetNumber4); scanf ("%lf", &BetAmount4);
  328.  
  329. srand(time(0));
  330. RouletteNumber = rand() %39;
  331.    switch (RouletteNumber)
  332.    { case 39: printf("Winning Roulette Number - 00 \n\n");
  333.    default: printf("Winning Roulette Number - %d \n\n", RouletteNumber);
  334.    }
  335. /* The reason in which I have used a switch statement over an IF statement as Swtich statements
  336. deal specifically with integer values and we are strictly working with integer values.*/   
  337.    
  338.    
  339. /*Bet 1*/
  340.  
  341. if (BetNumber1 <0)
  342. {  
  343. printf ("ERROR - Choose a Bet of 0 or above \n");
  344. exit(0);
  345. }
  346.  
  347. /* The reason I have used exit(0)as it will exit the process completely if the condition has been met
  348. in this case if the player inputs a Bet Number below 0, the process will display an error and the
  349. game cannot be played as inputting a negative number is an error as there are no negative numbers on
  350. a roulette table. */
  351.  
  352. if (BetNumber1 >= 39)
  353. {
  354. printf("Error Message - Choose a Number below 39 \n");
  355. }
  356.  
  357. if (BetAmount1 <=0)
  358. {
  359. printf("Error Message - Choose an Amount above 0 \n");
  360. }
  361.  
  362.  
  363. if (RouletteNumber == BetNumber1)
  364. { printf("Congratulations your number is winning number %d \n", BetNumber1);
  365.  
  366.  
  367.  if (BetNumber1 <0)
  368.   { printf ("ERROR - Choose a Bet of 0 or above \n");
  369.   }
  370.  
  371.    if (BetNumber1 == 38)
  372.   { printf ("Bet Number: 00 \n ");
  373.   }
  374.    else
  375.   {printf ("Bet Number: %d \n ", BetNumber1);
  376.   }
  377.   /*As this is American Roulette I have used 38 to represent as 00 and if the player choses 38 they
  378.   are choosing the roulette number of 00*/
  379.  
  380. printf ("Bet Amount: %.2lf \n",BetAmount1);
  381. PayOut1 = BetAmount1 * 35 + BetAmount1;
  382. printf("Payout: %.2lf \n", PayOut1);
  383. printf("Profit: %.2lf \n",(PayOut1 - BetAmount1));
  384. printf("Your New Total is: %.2lf \n\n",PayOut1);
  385. }
  386. /* For each of the winning PayOut values I have multiplied the BetAmount by 35 as according to Wikipedia
  387. in American Roulette which includes 00 the payout is 35 to 1, as well as this the player also receives
  388. their orginal bet amount back and so I have elongated the equation to add their original bet amount to
  389. the total of the bet amount * 35.
  390. Furthermore, in order to work out the players profit, I have subtracted their bet amount from their
  391. payout value as the profit in which the player makes is how much money they have won but minus the
  392. bet amount they put in as that is their money. */
  393.  
  394.    else
  395. {
  396. printf("The winning number is %d \n", RouletteNumber);
  397.  printf("You Have Not Won \n");
  398.  
  399.    
  400.    if (BetNumber1 <0)
  401.   { printf ("ERROR - Choose a Bet of 0 or above \n");
  402.   }
  403.    
  404. if(BetNumber1 == 38)
  405.   {   printf ("Bet Number: 00 \n");
  406.   }
  407.    else
  408.   {   printf ("Bet Number: %d \n", BetNumber1);
  409.   }
  410.  
  411.   printf ("Bet Amount: %.2lf \n", BetAmount1);
  412.   PayOut1 = BetAmount1 * -1;
  413.   printf("Payout: %.2lf\n",PayOut1);
  414.   printf("Loss: -%.2lf \n", BetAmount1);
  415.   printf("Your New Total is: %.2lf \n\n",PayOut1);
  416. }
  417.  
  418. /*Bet 2*/
  419.  
  420. if (BetNumber2 <0)
  421. {
  422. printf ("ERROR - Choose a Bet of 0 or above \n");
  423. exit(0);
  424. }
  425.    
  426. if (BetNumber2 >= 39)
  427. {
  428. printf("Error Message - Choose a Number below 39\n");
  429. }
  430.  
  431. if (BetAmount2 <=0)
  432. {
  433. printf("Error Message - Choose an Amount above 0\n");
  434. }
  435.  
  436.  
  437. if (RouletteNumber == BetNumber2)
  438. {
  439. printf("Congratulations your number is winning number %d \n", BetNumber2);
  440.  
  441.    if (BetNumber2 <0)
  442.   {   printf ("ERROR - Choose a Bet of 0 or above \n");
  443.   }
  444.  
  445.  
  446.    if (BetNumber2 == 38)
  447.   {   printf ("Bet Number: 00\n ");}
  448.    else
  449.   {   printf ("Bet Number: %d \n ", BetNumber2);
  450.   }
  451.  
  452. printf ("Bet Amount: %.2lf\n", BetAmount2);
  453. PayOut2 = BetAmount2 * 35 + BetAmount2;
  454. printf ("Payout: %.2lf\n", PayOut2);
  455. printf("Profit: %.2lf\n",(PayOut2 - BetAmount2));
  456. printf("Your New Total is: %.2lf \n\n",PayOut1 + PayOut2);
  457. }
  458.  
  459. else
  460. {
  461. printf("The winning number is %d \n", RouletteNumber);
  462. printf("You Have Not Won \n");
  463.  
  464. if (BetNumber2 <0)
  465.   {   printf ("ERROR - Choose a Bet of 0 or above");
  466.   }
  467.  
  468.    if (BetNumber2 == 38)
  469.   {   printf ("Bet Number: 00\n ");}
  470.    
  471.    else
  472.   {   printf ("Bet Number: %d \n", BetNumber2);
  473. printf ("Bet Amount: %.2lf \n",BetAmount2);
  474. PayOut2 = BetAmount2 * -1;
  475. printf("Payout: %.2lf\n",PayOut2);
  476. printf("Loss: -%.2lf \n",BetAmount2);
  477. printf("Your New Total is: %.2lf \n\n",PayOut1 - BetAmount2);
  478. }
  479. }
  480.  
  481. /* Bet 3 */
  482. if (BetNumber3 <0)
  483. {  
  484. printf ("ERROR - Choose a Bet of 0 or above \n");
  485. exit(0);
  486. }
  487.  
  488. if (BetNumber3 >= 39)
  489. {
  490. printf("Error Message - Choose a Number below 39 \n");
  491. }
  492.  
  493. if (BetAmount3 <=0)
  494. {
  495. printf("Error Message - Choose an Amount above 0 \n");
  496. }
  497.  
  498.  
  499. if (RouletteNumber == BetNumber3)
  500. {
  501. printf("Congratulations your number is winning number %d \n", BetNumber3);
  502.  
  503. if (BetNumber3 <0)
  504. {  
  505. printf ("ERROR - Choose a Bet of 0 or above \n");
  506. }
  507.  
  508.  if (BetNumber3 == 38)
  509.   {   printf ("Bet Number: 00 \n ");
  510.   }
  511.    else
  512.   {   printf ("Bet Number: %d \n ", BetNumber3);
  513.   }
  514.  
  515. printf ("Bet Amount: %.2lf \n", BetAmount3);
  516. PayOut3 = ((BetAmount3 * 35) + BetAmount3);
  517. printf("Payout: %.2lf \n", PayOut3);
  518. printf("Profit: %.2lf \n\n",(PayOut3 - BetAmount3));
  519. printf("Your New Total is: %.2lf \n\n",PayOut1 + PayOut2 + PayOut3);
  520. }
  521.  
  522. else
  523. {
  524. printf("The winning number is %d \n", RouletteNumber);
  525. printf("You Have Not Won \n");
  526.  
  527.    if (BetNumber3 <0)
  528.    {  
  529.    printf ("ERROR - Choose a Bet of 0 or above \n");
  530.    }
  531.    
  532.    if (BetNumber3 == 38)
  533.   {   printf ("Bet Number: 00 \n ");}
  534.    else
  535.   {   printf ("Bet Number: %d \n ", BetNumber3);}
  536.  
  537. printf("Bet Amount: %.2lf \n", BetAmount3);
  538. PayOut3 = BetAmount3 * -1;
  539. printf("Payout: %.2lf \n", PayOut3);
  540. printf("Loss: -%.2lf \n", BetAmount3);
  541. printf("Your New Total is: %.2lf \n\n",PayOut1 - BetAmount2 - BetAmount3);
  542. }
  543.  
  544. /* Bet 4 */
  545. if (BetNumber4 <0)
  546. {  
  547. printf ("ERROR - Choose a Bet of 0 or above \n");
  548. exit(0);
  549. }
  550.  
  551. if (BetNumber4 >= 39)
  552. {
  553. printf("Error Message - Choose a Number below 39\n");
  554. }
  555.  
  556. if (BetAmount4 <=0)
  557. {
  558. printf("Error Message - Choose an Amount above 0\n");
  559. }
  560.  
  561.  
  562. if (RouletteNumber == BetNumber4)
  563. {
  564. printf("Congratulations your number is winning number %d \n", BetNumber4);
  565.  
  566. if (BetNumber4 <0)
  567. {  
  568. printf ("ERROR - Choose a Bet of 0 or above \n");
  569. }
  570.  
  571. if (BetNumber4 == 38)
  572.   {   printf ("Bet Number: 00\n ");}
  573.    else
  574.   {   printf ("Bet Number: %d\n ", BetNumber4);
  575.   }
  576.  
  577. printf ("Bet Amount: %.2lf\n", BetAmount4);
  578. PayOut4 = ((BetAmount4 * 35) + BetAmount4);
  579. printf ("Payout: %.2lf\n", PayOut4);
  580. printf("Profit: %.2lf\n",(PayOut4 - BetAmount4));
  581. printf("Your New Total is: %.2lf \n\n",PayOut1 + PayOut2 + PayOut3 + PayOut4);
  582. }
  583.  
  584. else
  585. {
  586. printf("The winning number is %d \n", RouletteNumber);
  587. printf("You Have Not Won \n");
  588.  
  589. if (BetNumber4 <0)
  590. {  
  591. printf ("ERROR - Choose a Bet of 0 or above \n");
  592. }
  593.    
  594.    if (BetNumber4 == 38)
  595.   {   printf ("Bet Number: 00 \n");}
  596.    else
  597.   {   printf ("Bet Number: %d \n", BetNumber4);}
  598.  
  599.  
  600. printf ("Bet Amount: %.2lf \n", BetAmount4);
  601. PayOut4 = BetAmount4 * -1;
  602. printf("Payout: %.2lf\n",PayOut4);
  603. printf("Loss: -%.2lf \n", BetAmount4);
  604. printf("Your New Total is: %.2lf \n\n",PayOut1 - BetAmount2 - BetAmount3 - BetAmount4);
  605. }
  606.  
  607. TotalBetAmount = BetAmount1 + BetAmount2 + BetAmount3 + BetAmount4;
  608. TotalPayOut = PayOut1 + PayOut2 + PayOut3 + PayOut4;
  609. TotalProfitorLoss = TotalPayOut - TotalBetAmount;
  610.  
  611.  
  612. if (TotalPayOut > TotalBetAmount)
  613. { printf (" Your Total Profit is: %.2lf \n", TotalProfitorLoss);
  614. printf("The Total Made is: %.2lf \n", TotalPayOut);
  615. }
  616. else
  617. {
  618. printf ("Your Total Loss is: %.2lf \n", TotalBetAmount);
  619. }
  620. /*In order for a total profit or loss at the end of the simulation of all 4 bets, the total bet amount
  621. must be subtracted from the total pay out as if the total pay out is greater than the total bet amounts
  622. this means the player has made a profit whereas if the total bet amounts are greater than they total
  623. payout they have made a loss from this game.*/
  624.  
  625. }