<mosaic.cnfolio.com>
PROGRAM
1. /*
2. START
3. INPUT user inputs the number they bet on
4. INPUT user inputs the amount of money they wish to bet
5. STORE winning bet number variable and equate to 0
6. STORE payout variable and equate to 0
7. STORE total payout variable and equate to 0
8. STORE odds as 35/1
10. RANDOM function to pick random numbers
11. STORE random number from 0-37 in winning bet number variables
12. PRINT Program prints welcome message as well as intructions
13. IF Bet one number is less than 38 and greater than or equals to 0 THEN
14.    IF Bet one amount is greater than or equals to 1 THEN
15.       IF Bet one number equals to 37 THEN
16.          PRINT message saying bet has been placed on 00 as 37 will be used to represent 00
17.       ELSE
18.          PRINT the first bet number entered
19.       PRINT the amount entered on the first bet
20.       IF first winning bet number equals to 37 THEN
21.          PRINT message saying winning bet number is 00 as 37 will be used to represent 00
22.       ELSE
23.          PRINT the first winning bet number
24.       IF first bet number is equal to the first winning number THEN
25.          STORE first bet amount multiplied by odds in first payout variable
26.          STORE total payout add first payout add first bet amount in total payout variable
27.          PRINT the amount won in the first bet
28.          PRINT the subtotal of the bets so far
29.       ELSE
30.          STORE first bet amount in first payout variable
31.          STORE total payout minus the first payout in the total payout variable
32.          PRINT the amount lost in the second bet
33.          PRINT the subtotal so far
34.    ELSE
35.       PRINT error message that the first bet amount is too low
36. ELSE
37.    PRINT error message that the first bet number is not in range
38. IF Bet two number is less than 38 and greater than or equals to 0 THEN
39.    IF Bet two amount is greater than or equals to 1 THEN
40.       IF Bet two number equals to 37 THEN
41.          PRINT message saying bet has been placed on 00 as 37 will be used to represent 00
42.       ELSE
43.          PRINT the second bet number entered
44.       PRINT the amount entered on the second bet
45.       IF second winning bet number equals to 37 THEN
46.          PRINT message saying winning bet number is 00 as 37 will be used to represent 00
47.       ELSE
48.          PRINT the second winning bet number
49.       IF second bet number is equal to the second winning number THEN
50.          STORE second bet amount multiplied by odds in second payout variable
51.          STORE total payout add second payout add second bet amount in total payout variable
52.          PRINT the amount won in the second bet
53.          PRINT the subtotal of the bets so far
54.       ELSE
55.          STORE second bet amount in second payout variable
56.          STORE total payout minus the second payout in the total payout variable
57.          PRINT the amount lost in the second bet
58.          PRINT the subtotal so far
59.    ELSE
60.       PRINT error message that the second bet amount is too low
61. ELSE
62.    PRINT error message that the second bet number is not in range
63. IF Bet three number is less than 38 and greater than or equals to 0 THEN
64.    IF Bet three amount is greater than or equals to 1 THEN
65.       IF Bet three number equals to 37 THEN
66.          PRINT message saying bet has been placed on 00 as 37 will be used to represent 00
67.       ELSE
68.          PRINT the third bet number entered
69.       PRINT the amount entered on the third bet
70.       IF third winning bet number equals to 37 THEN
71.          PRINT message saying winning bet number is 00 as 37 will be used to represent 00
72.       ELSE
73.          PRINT the third winning bet number
74.       IF third bet number is equal to the third winning number THEN
75.          STORE third bet amount multiplied by odds in third payout variable
76.          STORE total payout add third payout add third bet amount in total payout variable
77.          PRINT the amount won in the third bet
78.          PRINT the subtotal of the bets so far
79.       ELSE
80.          STORE third bet amount in third payout variable
81.          STORE total payout minus the third payout in the total payout variable
82.          PRINT the amount lost in the third bet
83.          PRINT the subtotal so far
84.    ELSE
85.       PRINT error message that the third bet amount is too low
86. ELSE
87.    PRINT error message that the third bet number is not in range
88. IF Bet four number is less than 38 and greater than or equals to 0 THEN
89.    IF Bet four amount is greater than or equals to 1 THEN
90.       IF Bet four number equals to 37 THEN
91.          PRINT message saying bet has been placed on 00 as 37 will be used to represent 00
92.       ELSE
93.          PRINT the fourth bet number entered
94.       PRINT the amount entered on the fourth bet
95.       IF fourth winning bet number equals to 37 THEN
96.          PRINT message saying winning bet number is 00 as 37 will be used to represent 00
97.       ELSE
98.          PRINT the fourth winning bet number
99.       IF fourth bet number is equal to the fourth winning number THEN
100.          STORE fourth bet amount multiplied by odds in fourth payout variable
101.          STORE total payout add fourth payout add fourth bet amount in total payout variable
102.          PRINT the amount won in the fourth bet
103.          PRINT the subtotal of the bets so far
104.       ELSE
105.          STORE fourth bet amount in fourth payout variable
106.          STORE total payout minus the fourth payout in the total payout variable
107.          PRINT the amount lost in the fourth bet
108.          PRINT the subtotal so far
109.    ELSE
110.       PRINT error message that the fourth bet amount is too low
111. ELSE
112.    PRINT error message that the fourth bet number is not in range
113. PRINT the total made/lost from the bets
114. PRINT Program prints exit message
115. */
116. #include <stdio.h>
117. #include <stdlib.h>
118. #include <time.h>
119.
120. int main(void)
121. {
122. int betOneNumber; /* Declaring input variables */
123. float betOneAmount;
124. int betTwoNumber;
125. float betTwoAmount;
126. int betThreeNumber;
127. float betThreeAmount;
128. int betFourNumber;
129. float betFourAmount;
130.
131. int winning1=0; /* Declaring the variables used later */
132. int winning2=0;
133. int winning3=0;
134. int winning4=0;
135.
136. float payout1=0;
137. float payout2=0;
138. float payout3=0;
139. float payout4=0;
140.
141. float payoutTotal=0;
142.
143. int Odds=35/1; /* Assigning the odds to a variable */
144.
145. scanf("%d %f %d %f %d %f %d %f", &betOneNumber, &betOneAmount, &betTwoNumber, &betTwoAmount, &betThreeNumber, &betThreeAmount, &betFourNumber, &betFourAmount);
146.
147. srand(time(0)); /* Restarts random function */
148. winning1 = rand()%38; /* Picks a number between 0-37 */
149. winning2 = rand()%38;
150. winning3 = rand()%38;
151. winning4 = rand()%38;
152.
153. printf("Welcome to American Roulette! \n");
154. printf("To begin, enter the number you wish to bet on, between 0-36 and for 00 enter 37 \n");
155. printf("========================================================================================== \n");
156.
157. printf("\a Bet One \n");
158.
159. if (betOneNumber < 38 && betOneNumber >= 0) /* If statement to see if the bet number is between 0-37 */
160.    {
161.    if(betOneAmount >= 1) /* If statement to have at least a £1 bet */
162.    {
163.      if (betOneNumber == 37) /* If statement to check if bet number is equal to 37 */
164.         {
165.         printf("Your first bet has been placed on 00 \n"); /* Prints 00 */
166.         }
167.      else
168.         {
169.         printf("Your first bet has been placed on %d \n", betOneNumber); /* Otherwise prints the bet number entered */
170.         }
171.      printf("Your bet is £%.2f \n", betOneAmount); /* Prints the bet amount entered */
172.      if (winning1 == 37) /* If statement to check if bet number is equal to 37 */
173.         {
174.         printf("The first winning number is 00 \n"); /* Prints 00 */
175.         }
176.      else
177.         {
178.         printf("The first winning number is %d \n", winning1); /* Otherwise prints the winning bet number entered */
179.         }
180.      if (betOneNumber == winning1) /* Checks if the bet number is the same as the winning number */
181.         {
182.         payout1=(betOneAmount*Odds); /* Calculates the payout of the current bet */
183.         payoutTotal=(payoutTotal+payout1+betOneAmount); /* Calculates the subtotal so far */
184.         printf("CONGRATULATIONS! You have won £%.2f from your first bet \n", payout1+betOneAmount); /* Prints the bet payout */
185.         printf("Your subtotal is £%.2f \n \n", payoutTotal); /* Prints the subtotal */
186.         }
187.      else
188.         {
189.         payout1=(betOneAmount); /* Calculates the payout of the current bet */
190.         payoutTotal=(payoutTotal-payout1); /* Calculates the subtotal so far */
191.         printf("UNLUCKY! You have lost your first bet, you have a loss of -£%.2f \n", payout1); /* Prints the bet payout */
192.         printf("Your subtotal is £%.2f \n \n", payoutTotal); /* Prints the subtotal */
193.         }
194.       }
195.    else
196.       {
197.       printf("The amount you have bet first is too low, please enter an amount of at least £1.00 \n \n"); /* Prints error if the bet amount is too low */
198.       }
199.       }
200. else
201.    {
202.    printf("The number you have bet on first is out of range, please try again within the range of 0-36, or enter 37 to place a bet on 00 \n \n"); /* Prints error if the bet is not in the given range */
203.    }
204.
205. printf("\a Bet Two \n");
206.
207. if (betTwoNumber < 38 && betTwoNumber >= 0)
208.    {
209.    if(betTwoAmount >= 1)
210.    {
211.      if (betTwoNumber == 37)
212.         {
213.         printf("Your second bet has been placed on 00 \n");
214.         }
215.      else
216.         {
217.         printf("Your second bet has been placed on %d \n", betTwoNumber);
218.         }
219.      printf("Your bet is £%.2f \n", betTwoAmount);
220.      if (winning2 == 37)
221.         {
222.         printf("The second winning number is 00 \n");
223.         }
224.      else
225.         {
226.         printf("The second winning number is %d \n", winning2);
227.         }
228.      if (betTwoNumber == winning2)
229.         {
230.         payout2=(betTwoAmount*Odds);
231.         payoutTotal=(payoutTotal+payout2+betTwoAmount);
232.         printf("CONGRATULATIONS! You have won £%.2f from your second bet \n", payout2+betTwoAmount);
233.         printf("Your subtotal is £%.2f \n \n", payoutTotal);
234.         }
235.      else
236.         {
237.         payout2=(betTwoAmount);
238.         payoutTotal=(payoutTotal-payout2);
239.         printf("UNLUCKY! You have lost your second bet, you have a loss of -£%.2f \n", payout2);
240.         printf("Your subtotal is £%.2f \n \n", payoutTotal);
241.         }
242.       }
243.    else
244.       {
245.       printf("The amount you have bet second is too low, please enter an amount of at least £1.00 \n \n");
246.       }
247.       }
248. else
249.    {
250.    printf("The number you have bet on second is out of range, please try again within the range of 0-36, or enter 37 to place a bet on 00 \n \n");
251.    }
252.
253.    printf("\a Bet Three \n");
254.
255. if (betThreeNumber < 38 && betThreeNumber >= 0)
256.    {
257.    if(betThreeAmount >= 1)
258.    {
259.      if (betThreeNumber == 37)
260.         {
261.         printf("Your third bet has been placed on 00 \n");
262.         }
263.      else
264.         {
265.         printf("Your third bet has been placed on %d \n", betThreeNumber);
266.         }
267.      printf("Your bet is £%.2f \n", betThreeAmount);
268.      if (winning3 == 37)
269.         {
270.         printf("The third winning number is 00 \n");
271.         }
272.      else
273.         {
274.         printf("The third winning number is %d \n", winning3);
275.         }
276.      if (betThreeNumber == winning3)
277.         {
278.         payout3=(betThreeAmount*Odds);
279.         payoutTotal=(payoutTotal+payout3+betThreeAmount);
280.         printf("CONGRATULATIONS! You have won £%.2f from your third bet \n", payout3+betThreeAmount);
281.         printf("Your subtotal is £%.2f \n \n", payoutTotal);
282.         }
283.      else
284.         {
285.         payout3=(betThreeAmount);
286.         payoutTotal=(payoutTotal-payout3);
287.         printf("UNLUCKY! You have lost your third bet, you have a loss of -£%.2f \n", payout3);
288.         printf("Your subtotal is £%.2f \n \n", payoutTotal);
289.         }
290.       }
291.    else
292.       {
293.       printf("The amount you have bet third is too low, please enter an amount of at least £1.00 \n \n");
294.       }
295.       }
296. else
297.    {
298.    printf("The number you have bet on third is out of range, please try again within the range of 0-36, or enter 37 to place a bet on 00 \n \n");
299.    }
300.
301.    printf("\a Bet Four \n");
302.
303. if (betFourNumber < 38 && betFourNumber >= 0)
304.    {
305.    if(betFourAmount >= 1)
306.    {
307.      if (betFourNumber == 37)
308.         {
309.         printf("Your fourth bet has been placed on 00 \n");
310.         }
311.      else
312.         {
313.         printf("Your fourth bet has been placed on %d \n", betFourNumber);
314.         }
315.      printf("Your bet is £%.2f \n", betFourAmount);
316.      if (winning4 == 37)
317.         {
318.         printf("The fourth winning number is 00 \n");
319.         }
320.      else
321.         {
322.         printf("The fourth winning number is %d \n", winning4);
323.         }
324.      if (betFourNumber == winning4)
325.         {
326.         payout4=(betFourAmount*Odds);
327.         payoutTotal=(payoutTotal+payout4+betFourAmount);
328.         printf("CONGRATULATIONS! You have won £%.2f from your fourth bet \n", payout4+betFourAmount);
329.         printf("Your subtotal is £%.2f \n \n", payoutTotal);
330.         }
331.      else
332.         {
333.         payout4=(betFourAmount);
334.         payoutTotal=(payoutTotal-payout4);
335.         printf("UNLUCKY! You have lost your fourth bet, you have a loss of -£%.2f \n", payout4);
336.         printf("Your subtotal is £%.2f \n \n", payoutTotal);
337.         }
338.       }
339.    else
340.       {
341.       printf("The amount you have bet fourth is too low, please enter an amount of at least £1.00 \n \n");
342.       }
343.       }
344. else
345.    {
346.    printf("The number you have bet on fourth is out of range, please try again within the range of 0-36, or enter 37 to place a bet on 00 \n \n");
347.    }
348.
349.    printf("========================================================================================== \n");
350.    printf("Your total winnings/loss is £%.2f \n", payoutTotal); /* Prints total */
351.    printf("========================================================================================== \n");
352.    printf("Thank you for playing American Roulette, we hope you have enjoyed your time! \n"); /* Prints exit message */
353. }