<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3.    Scan For 8 inputs. 4 numbers that the player will bet on, and 4 amounts of money that the player will put on those bets
  4.    
  5.       IF The first bet number is less than 0 or more than 36 or not an integer, of if the money on that bet is less than $0 or more than $500,000 or not an integer
  6.          THEN 
  7.             Display error in bet 1 message
  8.             END code here
  9.          ELSE
  10.             Carry on with code
  11.     END IF
  12.      
  13.       IF The second bet number is less than 0 or more than 36 or not an integer, or if the money on that bet is less than $0 or more than $500,000 or not an integer
  14.          THEN 
  15.             Display error in bet 2 message
  16.             END code here
  17.          ELSE
  18.             Carry on with code
  19.     END IF
  20.      
  21.       IF The third bet number is less than 0 or more than 36 or not an integer, or if the money on that bet is less than $0 or more than $500,000 or not an integer
  22.          THEN 
  23.             Display error in bet 3 message
  24.             END code here
  25.          ELSE
  26.             Carry on with code
  27.     END IF
  28.      
  29.       IF The fourth bet number is less than 0 or more than 36 or not an integer, or if the money on that bet is less than $0 or more than $500,000 or not an integer
  30.          THEN 
  31.             Display error in bet 4 message
  32.             END code here
  33.          ELSE
  34.             Carry on with code
  35.     END IF
  36.  
  37.    Randomly generate a number between 1 and 37 - For spin 1
  38.    Put the generated number into a table of values to select an output number from 0 to 36. The 37th number will represent the value 00 on the roulette table
  39.       IF The randomly generated number = 37
  40.          THEN 
  41.             Display message telling the user that the first ball has landed on value 00
  42.          ELSE
  43.             Display message telling user that the first ball has landed on that random value (which will be between 0 and 36)
  44.       END IF
  45.      
  46.       IF the number randomly generated is asscosiated with the colour red
  47.          THEN 
  48.             Print message telling the user that the colour the first ball has landed on is red
  49.          ELSE
  50.             Print message telling the user that the colour the first ball has landed on is black
  51.       END IF
  52.          
  53.       IF The inputted bet number 1 is equal to what the random generator value
  54.          THEN
  55.             Times the amount that the user betted on ball 1 by 35. Display congratilations message followed by how much they have won
  56.          ELSE 
  57.             Display message teling the user that they have lost on their first bet. They have lost the amount that they betted on the first number
  58.       END IF
  59.  
  60.    Randomly generate a number between 1 and 37 - For spin2 2
  61.    Put the generated number into a table of values to select an output number from 0 to 36. The 37th number will represent the value 00 on the roulette table
  62.       IF The randomly generated number = 37
  63.          THEN 
  64.             Display message telling the user that the second ball has landed on value 00
  65.          ELSE
  66.             Display message telling user that the second ball has landed on that random value (which will be between 0 and 36)
  67.       END IF
  68.      
  69.       IF the number randomly generated is asscosiated with the colour red
  70.          THEN 
  71.             Print message telling the user that the colour the second ball has landed on is red
  72.          ELSE
  73.             Print message telling the user that the colour the second ball has landed on is black
  74.       END IF
  75.          
  76.       IF The inputted bet number 2 is equal to what the random generator value
  77.          THEN
  78.             Times the amount that the user betted on ball 2 by 35. Display congratilations message followed by how much they have won
  79.          ELSE 
  80.             Display message teling the user that they have lost on their second bet. They have lost the amount that they betted on the second number
  81.       END IF
  82.      
  83.    Randomly generate a number between 1 and 37 - For spin 3
  84.    Put the generated number into a table of values to select an output number from 0 to 36. The 37th number will represent the value 00 on the roulette table
  85.       IF The randomly generated number = 37
  86.          THEN 
  87.             Display message telling the user that the third ball has landed on value 00
  88.          ELSE
  89.             Display message telling user that the third ball has landed on that random value (which will be between 0 and 36)
  90.       END IF
  91.      
  92.       IF the number randomly generated is asscosiated with the colour red
  93.          THEN 
  94.             Print message telling the user that the colour the third ball has landed on is red
  95.          ELSE
  96.             Print message telling the user that the colour the third ball has landed on is black
  97.       END IF
  98.          
  99.       IF The inputted bet number 3 is equal to what the random generator value
  100.          THEN
  101.             Times the amount that the user betted on ball 3 by 35. Display congratilations message followed by how much they have won
  102.          ELSE 
  103.             Display message teling the user that they have lost on their third bet. They have lost the amount that they betted on the third number
  104.       END IF     
  105.      
  106.   Randomly generate a number between 1 and 37 - For spin 4
  107.    Put the generated number into a table of values to select an output number from 0 to 36. The 37th number will represent the value 00 on the roulette table
  108.       IF The randomly generated number = 37
  109.          THEN 
  110.             Display message telling the user that the fourth ball has landed on value 00
  111.          ELSE
  112.             Display message telling user that the fourth ball has landed on that random value (which will be between 0 and 36)
  113.       END IF
  114.      
  115.       IF the number randomly generated is asscosiated with the colour red
  116.          THEN 
  117.             Print message telling the user that the colour the fourth ball has landed on is red
  118.          ELSE
  119.             Print message telling the user that the colour the fourth ball has landed on is black
  120.       END IF
  121.          
  122.       IF The inputted bet number 4 is equal to what the random generator value
  123.          THEN
  124.             Times the amount that the user betted on ball 4 by 35. Display congratilations message followed by how much they have won
  125.          ELSE 
  126.             Display message teling the user that they have lost on their fourth bet. They have lost the amount that they betted on the fourth number
  127.       END IF
  128.      
  129.   Use the outputs of the previous caluclations to calculate the profit made and the amount left in the user's 'wallet'
  130.       IF The profit is greater than 0
  131.          THEN
  132.             Display congratulations message and the total profit made. Then the amount in the user's wallet
  133.          ELSE
  134.             Carry on with code
  135.       END IF
  136.      
  137.       IF The profit is equal to 0
  138.        THEN
  139.             Display message telling the user they have broke even. Their profit will be 0 and their wallet will have the same amount as the inputted
  140.          ELSE
  141.             Carry on with code
  142.       END IF
  143.      
  144.       IF The profit is less than 0
  145.          THEN
  146.             Display message telling user they have made no profit. Display profit made (Which will be negative) and the amount the user has in their wallet
  147.          ELSE
  148.             Carry on with code
  149.            
  150. END
  151.  
  152. */
  153.  
  154. #include <stdio.h>
  155. #include <string.h>
  156. #include <time.h>
  157.  
  158. int main (void)
  159.     {
  160.       int ball1, ball2, ball3, ball4, total1=0, total2=0, total3=0, total4=0, profit=0, initial_wallet=0, final_wallet=0/*Declare these variables as integers, and make some of them =0 stop random values beng created if nothing is inputted*/
  161.       int one=0, two=0, three=0, four=0, bet1=0, bet2=0, bet3=0, bet4=0, number1, number2, number3, number4;  /*Declare these variables as integers. Some are not made =0 becasue they will be almost instantly given a value in this code*/
  162.       scanf("%d %d %d %d %d %d %d %d", &one, &bet1, &two, &bet2, &three, &bet3, &four, &bet4);   /*Scan the input for all 4 bets. Going in order of what number you want to bet on, followed by how much money you will put on that number*/
  163.       float table[38] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37}/*Create an array of 38 values. This will mean the range of values will be from 0 to 37. The 37th value will eventually become the value 00 as it is seperate to 0*/
  164.      
  165.          if ((bet1<=0)||(bet1>500000)||(one>37)||(one<0))   /*If the first number the user is betting on is less than 0 or greater than 37, or the value of money put on the first bet is equal to or less than 0, or greater than 500,000*/
  166.             {
  167.                printf("Error in Bet1: Make sure the number you are betting on is between 0 and 36. Make sure your amount you are betting with is greater than $0 but is $500,000 or less. \nUse the number 37 if you would like to bet on number 00.")/*Print this error message*/
  168.                return 0;   /*Stop the code at this point so it can't go on further and make incorrect calculations*/
  169.             }
  170.      
  171.             else if ((bet2<=0)||(bet2>500000)||(two>37)||(two<0)) /*Else, if the second number the user is betting on is less than 0 or greater than 37, or the value of money put on the second bet is equal to or less than 0, or greater than 500,000*/
  172.                {
  173.                   printf("Error in Bet2: Make sure the number you are betting on is between 0 and 36. Make sure your amount you are betting with is greater than $0 but is $500,000 or less. \nUse the number 37 if you would like to bet on number 00.")/*Print this error message*/
  174.                   return 0;   /*Stop the code at this point so it can't go on further and make incorrect calculations*/
  175.                }
  176.      
  177.            else if ((bet3<=0)||(bet3>500000)||(three>37)||(three<0))  /*Else, if the third number the user is betting on is less than 0 or greater than 37, or the value of money put on the third bet is equal to or less than 0, or greater than 500,000*/
  178.                {
  179.                   printf("Error in Bet3: Make sure the number you are betting on is between 0 and 36. Make sure your amount you are betting with is greater than $0 but is $500,000 or less. \nUse the number 37 if you would like to bet on number 00.")/*Print this error message*/
  180.                   return 0;   /*Stop the code at this point so it can't go on further and make incorrect calculations*/
  181.                }
  182.      
  183.            else if ((bet4<=0)||(bet4>500000)||(four>37)||(four<0)) /*Else, if the fourth number the user is betting on is less than 0 or greater than 37, or the value of money put on the fourth bet is equal to or less than 0, or greater than 500,000*/
  184.                {
  185.                   printf("Error in Bet4: Make sure the number you are betting on is between 0 and 36. Make sure your amount you are betting with is greater than $0 but is $500,000 or less. \nUse the number 37 if you would like to bet on number 00.")/*Print this error message*/
  186.                   return 0;   /*Stop the code at this point so it can't go on further and make incorrect calculations*/
  187.                }
  188.      
  189.          else
  190.             {
  191.                printf("Welcome!\n\n"); /*If there are no errors in the input form the user then the code will move onto the main code. Stationg with a "Wlecome!" message*/
  192.           } 
  193.          
  194.          
  195.          if (one==37)   /* If the value inputted for the first bet is 37 (meaning the user wants to bet on value 00)*/
  196.             {
  197.                printf("Bet1 - You have put $%d on number 00\n", bet1); /*Print this initial message telling the user that this is their first bet and how much they are betting on value 00 - 00 is in text form as it can't be differentiated from 0 in numeric form*/
  198.             }
  199.          else
  200.             {
  201.                printf("Bet1 - You have put $%d on number %d\n", bet1, one); /*If the inputted value for bet 1 is not 37, then print this message telling the user what value they have betted on and how much they have put on it*/           
  202.             }
  203.                
  204.          if (two==37)   /* If the value inputted for the second bet is 37 (meaning the user wants to bet on value 00)*/
  205.             {
  206.                printf("Bet2 - You have put $%d on number 00\n", bet2)/*Print this initial message telling the user that this is their second bet and how much they are betting on value 00*/
  207.             }
  208.          else
  209.             {
  210.                printf("Bet2 - You have put $%d on number %d\n", bet2, two);   /*If the inputted value for bet 2 is not 37, then print this message telling the user what value they have betted on and how much they have put on it*/
  211.             }
  212.            
  213.          if (three==37) /* If the value inputted for the third bet is 37 (meaning the user wants to bet on value 00)*/
  214.             {
  215.                printf("Bet3 - You have put $%d on number 00\n", bet3)/*Print this initial message telling the user that this is their third bet and how much they are betting on value 00*/
  216.             }
  217.          else
  218.             {
  219.                printf("Bet3 - You have put $%d on number %d\n", bet3, three)/*If the inputted value for bet 3 not 37, then print this message telling the user what value they have betted on and how much they have put on it*/
  220.             }
  221.            
  222.          if (four==37)  /* If the value inputted for the fourth bet is 37 (meaning the user wants to bet on value 00)*/
  223.             {
  224.                printf("Bet4 - You have put $%d on number 00\n\n", bet4);   /*Print this initial message telling the user that this is their fourth bet and how much they are betting on value 00*/
  225.             }
  226.          else
  227.             {
  228.                printf("Bet4 - You have put $%d on number %d\n\n", bet4, four);   /*If the inputted value for bet 4 is not 37 then print this message telling the user what value they have betted on and how much they have put on it*/
  229.             }
  230.       srand (time(0)); /*Begin the random generator*/
  231.      
  232.       initial_wallet=bet1+bet2+bet3+bet4; /*The initial amount in the users wallet is calculated by adding up the total amount of money they have put into the 4 bets*/
  233.            
  234.       number1 = rand()%38; /*The first random number is generated for the first bet. Between 0 and 37*/
  235.       ball1 = table[number1]; /*This number is the put into the array which holds the table of values*/
  236.          if (ball1 == 37) /*If the random value generated =37 (meaning that it has landed on 00)*/
  237.             {
  238.                printf("Ball 1 has landed on number 00.");   /*Print this message telling the user that the first ball has landed on 00*/
  239.             }
  240.                
  241.          else
  242.             {
  243.             printf("Ball 1 has landed on number %d ", ball1)/*If the random generator has not generated the number 37, then print this messsage telling the user what number the first ball has landed on*/
  244.                if (ball1==1||ball1==3||ball1==5||ball1==7||ball1==9||ball1==12||ball1==14||ball1==16||ball1==18||ball1==19||ball1==21||ball1==23||ball1==25||ball1==27||ball1==30||ball1==32||ball1==34||ball1==36) /*If the random value generated for ball 1 is any of the values which are red on the roulette table*/
  245.                   { 
  246.                      printf("(RED). ");   /*Print message telling the user that the first ball has landed on the colour red*/
  247.                   }
  248.                else if (ball1==0) /*If the random value generated for ball 1 is the number 0*/
  249.                   {
  250.                      printf(". ")/*Print just a fullstop as 0 and 00 are both the colour green (not relevant to the bet)*/
  251.                   }
  252.                else
  253.                   {
  254.                      printf("(BLACK). "); /*Otherwise, the colour ball 1 has 'landed' on will be balck. So print message telling the user that ball 1 has landed on the colour balck*/
  255.                   }
  256.             }
  257.            
  258.          
  259.           if (one==ball1)  /*If the first randomly generated number matches the fist betting number the user inputted*/
  260.             {
  261.             printf(" Congratulations! you have won $%d\n", 35*bet1); /*Print a congratulations message followed by how much they have won (35*The amount of money they betted)*/
  262.                total1=(35*bet1)/*Store how much they won on the first in the variable 'total1'*/
  263.           }
  264.                  
  265.         else
  266.             {
  267.                printf("You have lost $%d on this spin!\n", bet1)/*If the numbers do not match, then display the losing message and how much they lost on that spin. The user loses what the put into the bet initially*/
  268.                total1=(-bet1); /*Store how much they lost in the fist bet in the variable 'total1' (The negative of the value the put in)*/
  269.             }
  270.  
  271.       number2 = rand()%38/*The second random number is generated for the first bet. Between 0 and 37*/
  272.       ball2 = table[number2];   /*This number is the put into the array which holds the table of values*/
  273.          if (ball2 == 37)  /*If the random value generated =37 (meaning that it has landed on 00)*/
  274.             {
  275.                printf("Ball 2 has landed on number 00.");   /*Print this message telling the user that the second ball has landed on 00*/
  276.             }
  277.                
  278.          else
  279.             {
  280.             printf("Ball 2 has landed on number %d ", ball2)/*If the random generator has not generated the number 37, then print this messsage telling the user what number the second ball has landed on*/
  281.                if (ball2==1||ball2==3||ball2==5||ball2==7||ball2==9||ball2==12||ball2==14||ball2==16||ball2==18||ball2==19||ball2==21||ball2==23||ball2==25||ball2==27||ball2==30||ball2==32||ball2==34||ball2==36)  /*If the random value generated for ball 2 is any of the values which are red on the roulette table*/
  282.                   { 
  283.                      printf("(RED). ");   /*Print message telling the user that the second ball has landed on the colour red*/
  284.                   }
  285.                else if (ball2==0) /*If the random value generated for ball 2 is the number 0*/
  286.                   {
  287.                      printf(". ")/*Print just a fullstop as 0 and 00 are both the colour green (not relevant to the bet)*/
  288.                   }
  289.                else
  290.                   {
  291.                      printf("(BLACK). ")/*Otherwise, the colour ball 2 has 'landed' on will be balck. So print message telling the user that ball 2 has landed on the colour balck*/
  292.                   }
  293.             }
  294.            
  295.          
  296.           if (two==ball2)  /*If the second randomly generated number matches the second betting number the user inputted*/
  297.             {
  298.             printf(" Congratulations! you have won %d\n", 35*bet2)/*Print a congratulations message followed by how much they have won (35*The amount of money they betted)*/
  299.                total2=(35*bet2)/*Store how much they won on the second in the variable 'total2'*/
  300.           }
  301.                  
  302.         else
  303.             {
  304.                printf("You have lost $%d on this spin!\n", bet2)/*If the numbers do not match, then display the losing message and how much they lost on that spin. The user loses what the put into the bet initially*/
  305.                total2=(-bet2);   /*Store how much they lost in the second bet in the variable 'total2' (The negative of the value the put in)*/
  306.              } 
  307.                
  308.     number3 = rand()%38/*The third random number is generated for the first bet. Between 0 and 37*/
  309.       ball3 = table[number3];   /*This number is the put into the array which holds the table of values*/
  310.          if (ball3 == 37)  /*If the random value generated =37 (meaning that it has landed on 00)*/
  311.             {
  312.                printf("Ball 3 has landed on number 00.");   /*Print this message telling the user that the third ball has landed on 00*/
  313.             }
  314.                
  315.          else
  316.             {
  317.             printf("Ball 3 has landed on number %d ", ball3)/*If the random generator has not generated the number 37, then print this messsage telling the user what number the third ball has landed on*/
  318.                if (ball3==1||ball3==3||ball3==5||ball3==7||ball3==9||ball3==12||ball3==14||ball3==16||ball3==18||ball3==19||ball3==21||ball3==23||ball3==25||ball3==27||ball3==30||ball3==32||ball3==34||ball3==36)  /*If the random value generated for ball 3 is any of the values which are red on the roulette table*/
  319.                   { 
  320.                      printf("(RED). ");   /*Print message telling the user that the third ball has landed on the colour red*/
  321.                   }
  322.                else if (ball3==0) /*If the random value generated for ball 3 is the number 0*/
  323.                   {
  324.                      printf(". ")/*Print just a fullstop as 0 and 00 are both the colour green (not relevant to the bet)*/
  325.                   }
  326.                else
  327.                   {
  328.                      printf("(BLACK). ")/*Otherwise, the colour ball 3 has 'landed' on will be balck. So print message telling the user that ball 3 has landed on the colour balck*/
  329.                   }
  330.             }
  331.            
  332.          
  333.           if (three==ball3)   /*If the third randomly generated number matches the third betting number the user inputted*/
  334.             {
  335.             printf(" Congratulations! you have won %d\n", 35*bet3)/*Print a congratulations message followed by how much they have won (35*The amount of money they betted)*/
  336.                total3=(35*bet3)/*Store how much they won on the third in the variable 'total3'*/
  337.           }
  338.                  
  339.         else
  340.             {
  341.                printf("You have lost $%d on this spin!\n", bet3)/*If the numbers do not match, then display the losing message and how much they lost on that spin. The user loses what the put into the bet initially*/
  342.                total3=(-bet3);   /*Store how much they lost in the third bet in the variable 'total3' (The negative of the value the put in)*/
  343.             }
  344.            
  345.       number4 = rand()%38;   /*The fourth random number is generated for the first bet. Between 0 and 37*/
  346.       ball4 = table[number4];   /*This number is the put into the array which holds the table of values*/
  347.          if (ball4 == 37)  /*If the random value generated =37 (meaning that it has landed on 00)*/
  348.             {
  349.                printf("Ball 4 has landed on number 00.");   /*Print this message telling the user that the fourth ball has landed on 00*/
  350.             }
  351.                
  352.          else
  353.             {
  354.             printf("Ball 4 has landed on number %d ", ball4)/*If the random generator has not generated the number 37, then print this messsage telling the user what number the fourth ball has landed on*/
  355.                if (ball4==1||ball4==3||ball4==5||ball4==7||ball4==9||ball4==12||ball4==14||ball4==16||ball4==18||ball4==19||ball4==21||ball4==23||ball4==25||ball4==27||ball4==30||ball4==32||ball4==34||ball4==36)  /*If the random value generated for ball 4 is any of the values which are red on the roulette table*/
  356.                   { 
  357.                      printf("(RED). ");   /*Print message telling the user that the fourth ball has landed on the colour red*/
  358.                   }
  359.                else if (ball4==0) /*If the random value generated for ball 4 is the number 0*/
  360.                   {
  361.                      printf(". ")/*Print just a fullstop as 0 and 00 are both the colour green (not relevant to the bet)*/
  362.                   }
  363.                else
  364.                   {
  365.                      printf("(BLACK). ")/*Otherwise, the colour ball 4 has 'landed' on will be balck. So print message telling the user that ball 4 has landed on the colour balck*/
  366.                   }
  367.             }
  368.            
  369.          
  370.           if (four==ball4) /*If the fourth randomly generated number matches the fourth betting number the user inputted*/
  371.             {
  372.             printf(" Congratulations! you have won %d\n\n", 35*bet4)/*Print a congratulations message followed by how much they have won (35*The amount of money they betted)*/
  373.                total4=(35*bet4)/*Store how much they won on the fourth in the variable 'total4'*/
  374.           }
  375.                  
  376.         else
  377.             {
  378.                printf("You have lost $%d on this spin!\n\n", bet4)/*If the numbers do not match, then display the losing message and how much they lost on that spin. The user loses what the put into the bet initially*/
  379.                total4=(-bet4);   /*Store how much they lost in the fourth bet in the variable 'total4' (The negative of the value the put in)*/
  380.             }
  381.            
  382.        profit=total1+total2+total3+total4;   /*The profit made will be what all the totals of each bet add up to*/
  383.        final_wallet=initial_wallet+total1+total2+total3+total4; /*The final amount in the users wallet will be what the user initially had, minus the totals. This mean that if the user wins then 36*that winning will be in the wallet (as you also get the money back that you bet with), but if they lose, then they have lost what the put on that bet*/
  384.          if (0<(profit)) /*If the profit is greater than 0 - meaning the user has made a profit*/
  385.             {
  386.                printf("Well done! You made a profit of $%d. You now have $%d in your wallet",profit, final_wallet); /*Print a well done message followed by how much profit they made and how much they have in their wallet*/
  387.             }
  388.          else if (profit==0) /*If the profit is equal to 0 - meaning they have 'broken even'*/
  389.             {
  390.                printf("You have broken even! You have made a $0 profit. You now have $%d in your wallet.", final_wallet); /*Print the broken even message and how much they have in their wallet*/
  391.             }
  392.          else
  393.             {
  394.                printf("Unlcuky! You haven't made a proft. Your profit is $%d. You now have $%d in your wallet. Better luck next time!", profit, final_wallet); /*If the output is neither of the last two, then this means the user has made negative profit (No profit). Therefore, print the no profit message followed by the negative profit and how mcu hthey have in their wallet*/
  395.             }
  396.             }