<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3.  
  4. Set betnumber1
  5. Set betnumber2
  6. Set betnumber3
  7. Set betnumber4
  8. Set first bet amount to zero
  9. set second bet amount to zero
  10. Set thrid bet amount to zero
  11. Set forth bet amount to zero
  12. Set Result
  13. Set payout
  14. Set payout2
  15. Set payout3
  16. Set payout4
  17. Set Total
  18. Set Total2
  19. Set Total3
  20. Set Total4
  21. Set Startamount
  22. Set Profit/loss
  23. Set OverallWinnings to equil all the totals added together
  24. Read 4 Betnumbers
  25. Read 4 Betamounts
  26.  
  27. Set Startamount to equil betamount + betamount2 + betamount3 + betamount4
  28.  
  29. pick 4 random numbers between 0 and 37 which will be used as the result
  30.  
  31.  
  32.  
  33. IF Betnumbet1 is less than 0 or greater than 38
  34.    THEN
  35.       Display error message stating you have inputted an invalid bet number
  36.    ELSE
  37.       IF Betamount1 is less than 1 or is left blank
  38.          THEN
  39.             Display an error message telling the user they have placed an invalid bet amount
  40.       END IF
  41. END IF
  42.  
  43. IF Betnumbet2 is less than 0 or greater than 38
  44.    THEN
  45.       Display error message stating you have inputted an invalid bet number
  46.    ELSE
  47.       IF Betamount2 is less than 1 or is left blank
  48.          THEN
  49.             Display an error message telling the user they have placed an invalid bet amount
  50.       END IF
  51. END IF
  52.  
  53. IF Betnumbet3 is less than 0 or greater than 38
  54.    THEN
  55.       Display error message stating you have inputted an invalid bet number
  56.    ELSE
  57.       IF Betamount3 is less than 1 or is left blank
  58.          THEN
  59.             Display an error message telling the user they have placed an invalid bet amount
  60.       END IF
  61. END IF
  62.  
  63. IF Betnumbet4 is less than 0 or greater than 38
  64.    THEN
  65.       Display error message stating you have inputted an invalid bet number
  66.    ELSE
  67.       IF Betamount4 is less than 1 or is left blank
  68.          THEN
  69.             Display an error message telling the user they have placed an invalid bet amount
  70.       END IF
  71. END IF
  72.  
  73. IF Betnumber is equil to Result
  74.    THEN
  75.       Spin the Roulette Wheel with numbers 0 to 37 (37 to represent 00)
  76.       Display Betamount
  77.       Display BetNumber
  78.       Display Winning number
  79.       Add Betamount to payout
  80.       Multiply payout(winnings) by 35
  81.    ELSE
  82.       Display Betamount
  83.       Display BetNumber
  84.       Display Winning number
  85.       Add Betamount to payout
  86.       Multiply payout by -1
  87. END IF   
  88.  
  89. IF Betnumber2 is equil to Result
  90.    THEN
  91.       Spin the Roulette Wheel with numbers 0 to 37 (37 to represent 00)
  92.       Display Betamount2
  93.       Display BetNumber2
  94.       Display Winning number
  95.       Add Betamout2 to payout2
  96.       Multiply payout2(winnings) by 35
  97.    ELSE
  98.       Display Betamount2
  99.       Display BetNumber2
  100.       Display Winning number
  101.       Add Betamount2 to payout2
  102.       Multiply payout2 by -1
  103. END IF   
  104.  
  105. IF Betnumber3 is equil to Result
  106.    THEN
  107.       Spin the Roulette Wheel with numbers 0 to 37 (37 to represent 00)
  108.       Display Betamount3
  109.       Display BetNumber3
  110.       Display Winning number
  111.       Add Betamout3 to payout3
  112.       Multiply payout3(winnings) by 35
  113.    ELSE
  114.       Display Betamount3
  115.       Display BetNumber3
  116.       Display Winning number
  117.       Add Betamount3 to payout3
  118.       Multiply payout3 by -1
  119. END IF   
  120.  
  121. IF Betnumber4 is equil to Result
  122.    THEN
  123.       Spin the Roulette Wheel with numbers 0 to 37 (37 to represent 00)
  124.       Display Betamount4
  125.       Display BetNumber4
  126.       Display Winning number
  127.       Add Betamout4 to payout4
  128.       Multiply payout4(winnings) by 35
  129.    ELSE
  130.       Display Betamount4
  131.       Display BetNumber4
  132.       Display Winning number
  133.       Add Betamount4 to payout4
  134.       Multiply payout4 by -1
  135. END IF   
  136.  
  137. IF the overall is greater than the  start amount
  138.    THEN
  139.       Display the total amount earned in
  140.       Display the total profit made in
  141.    ELSE
  142.       Display the total lost in
  143. END IF
  144.  
  145. Display the total spent over 4 bets
  146. END
  147. */
  148. #include <stdio.h>
  149. #include <stdlib.h>
  150. #include <time.h>
  151.  
  152. int main (void)
  153. {
  154.    int result;
  155.    /* the reason for setting bet numbers to -1 and the bet amounts to 0 is because if i run the program with no inputs
  156.    and without setting these values the compiler outputs really random numbers. So by setting the intial values to 0 and -1 i
  157.    gain control over my outputs and this also allows my error checking to work correctly*/
  158.    int betnumber = -1;
  159.    int betnumber2 = -1;
  160.    int betnumber3 = -1;
  161.    int betnumber4 = -1;
  162.    int betamount=0;
  163.    int betamount2=0;
  164.    int betamount3=0;
  165.    int betamount4=0;
  166.    int payout;
  167.    int payout2;
  168.    int payout3;
  169.    int payout4;
  170.    int startamount;
  171.    int profitloss;
  172.    int total;
  173.    int total2;
  174.    int total3;
  175.    int total4;
  176.    
  177.    scanf("%d %d", &betnumber, &betamount);
  178.    scanf("%d %d", &betnumber2, &betamount2);
  179.    scanf("%d %d", &betnumber3, &betamount3);
  180.    scanf("%d %d", &betnumber4, &betamount4);
  181.    
  182.    startamount = (betamount + betamount2 + betamount3 + betamount4);
  183.     srand(time(0));
  184.    result = rand() %38; /*take 37 as the value to represent 00, this command sets the variable result to equil whatever number is randomly generated*/
  185.  
  186.    
  187.    /*for the error messaging i have used 4 IF statements so that i can have more control over the outputs, by doing this i can tell the user exactly where the error is
  188.    within the conditions i have used the or (||) function so that i can have 2 seperate conditions in one statement, this gives me a lot more
  189.    flexability. within the else if i have set the conditions for the betamounts, so that if there is an error with the input of amounts
  190.    this part of the if statement will handle the code.*/
  191.    if (betnumber <0 || betnumber > 38)
  192.    {
  193.       printf("Please choose a number that between 0 and 37");
  194.       exit(0);
  195.    }
  196.    else if (betamount < 1 || betamount == "")
  197.    {
  198.       printf("You have inputted an invaid bet amount\nPlease input a valid bet amount");
  199.       exit(0);
  200.    }
  201.    
  202.    if (betnumber2 <0 || betnumber2 > 38)
  203.    {
  204.       printf("Please choose a number that between 0 and 37");
  205.       exit(0);
  206.    }
  207.    else if (betamount2 < 1 || betamount2 == "")
  208.    {
  209.       printf("You have inputted an invaid bet amount\nPlease input a valid bet amount");
  210.       exit(0);
  211.    }
  212.    
  213.    if (betnumber3 <0 || betnumber3 > 38)
  214.    {
  215.       printf("Please choose a number that between 0 and 37");
  216.       exit(0);
  217.    }
  218.    else if (betamount3 < 1 || betamount3 == "")
  219.    {
  220.       printf("You have inputted an invaid bet amount\nPlease input a valid bet amount");
  221.       exit(0);
  222.    }
  223.    if (betnumber4 <0 || betnumber4 > 38)
  224.    {
  225.       printf("Please choose a number that between 0 and 37 4");
  226.       exit(0);
  227.    }
  228.    else if (betamount4 < 1 || betamount4 == "")
  229.    {
  230.       printf("You have inputted an invaid bet amount\nPlease input a valid bet amount");
  231.       exit(0);
  232.    }
  233.    
  234.    /*for the bets placed and the bet numbers chosen i have decied to work out the winning number and winning amounts in different IF statements because i am more confident using
  235.    this method than i am when it comes to using an array, i also used IF statements because i like to see all the processs and i like to have the ability to control each result for each number
  236.    so that if one IF statment has a problem i only have to solve the one problem instead of the possibility of having an array that has been configured incorrectly.*/
  237.    if (betnumber == result)/*within this statement and all the other if and else if statements i have used the total variable to store the calculated payout and the bet amount and by adding them together the player gets back their original bet as well as the winnings.*/
  238.    {
  239.       payout = betamount*35
  240.       total = payout+betamount;
  241.       printf("Bet 1\nYour Bet Number is: %d\nYou have placed a %d bet\nWinning number is: %d\nCongratulations you have won %d\n",betnumber,betamount,result, payout);
  242.       printf("your new total is %d\n\n", total);
  243.    }
  244.    else
  245.    {
  246.       payout = betamount*(-1);
  247.       total =payout;
  248.       printf("Bet 1\nYour Bet Number is: %d\nYou have placed a %d bet\nThe winning number is: %d\nYou have lost %d\n",betnumber,betamount,result,payout);
  249.       printf("your new total is %d\n\n", total);
  250.    }
  251.    
  252.    
  253.    if (betnumber2 == result)
  254.    {
  255.       payout2 = betamount2*35;
  256.       total2 = payout2 + betamount2;
  257.       printf("Bet 2\nYour Bet Number is: %d\nYou have placed a %d\nThe Winning number is: %d\nCongratulations you have won %d\n",betnumber2,betamount2,result, payout2);
  258.       printf("your new total is %d\n\n", (total+total2));
  259.    }
  260.    else
  261.    {
  262.       payout2 = betamount2*(-1);
  263.       total2 = payout2;
  264.       printf("Bet2\nYour Bet Number is: %d\nYou have placed a %d bet\nThe winning number is: %d\nYou have lost %d\n",betnumber2,betamount2,result, payout2);
  265.       printf("your new total is %d\n\n", (total + total2))
  266.    }
  267.  
  268.    if (betnumber3 == result)
  269.    {
  270.       payout3 = betamount3*35;
  271.       total3 = payout3 + betamount3;
  272.       printf("Bet 3\nYour Bet Number is: %d\nYou have placed a %d bet\nWinning number is: %d\nCongratulations you have won %d\n",betnumber3,betamount3,result, payout3);
  273.       printf("your new total is %d\n\n", (total+total2+total3));
  274.    }
  275.    else
  276.    {
  277.       payout3 = betamount3*(-1);
  278.       total3 = payout3;
  279.       printf("Bet 3\nYour Bet Number is: %d\nYou have placed a %d bet\nThe winning number is: %d\nYou have lost %d\n",betnumber3,betamount3,result, payout3);
  280.     printf("your new total is %d\n\n", (total+total2+total3));
  281.    }
  282.  
  283.    if (betnumber4 == result)
  284.    {
  285.       payout4 = betamount4*35;
  286.       total4 = payout4 + betamount4;
  287.       printf("Bet 4\nYour Bet Number is: %d\nYou have placed a %d bet\nWinning Number is: %d\nCongratulations you have won %d\n",betnumber4,betamount4,result, payout4);
  288.       printf("your new total %d\n\n",(total+total2+total3+total4));
  289.    }
  290.    else
  291.    {
  292.       payout4 = betamount4*(-1);
  293.       total4 = payout4;
  294.       printf("Bet 4\nYour Bet Number is: %d\nYou have placed a %d bet\nThe winning number is: %d\nYou have lost %d\n",betnumber4,betamount4,result, payout4);
  295.       printf("your new total %d\n\n",(total+total2+total3+total4));
  296.    }
  297.    
  298.    /*i have created a new variable called overall and i am using it so i can display the final winnings by adding up all of the
  299.    totals and storing the value in this variable. i have also used overall in the profitloss calculation and this new figure wil be shown
  300.    to the user to tell them how much profit they have made or how much they have lost, this will be determined using the if statement which
  301.    is comapring the final overall value to the start amount and if the new value is greater than the start amount then the player
  302.    will be told how much he has won and how much profit has been made.*/
  303.    int overall;
  304.    overall = total + total2 + total3 + total4;
  305.    profitloss = overall - startamount;
  306.  
  307.    if (overall > startamount)
  308.    {
  309.       printf("the total earned is %d\n The Total Profit made is %d", overall,profitloss);
  310.    }
  311.    else
  312.    {
  313.       printf("the total lost is %d", overall)
  314.    }
  315.    printf("\nthe total amount placed is %d", startamount);
  316.  }