<mosaic.cnfolio.com>
PROGRAM
1. /*Pseudo Code
2. START
3. User inputs 4 pairs of numbers (money and bet number)
4. Store numbers for roulette table (0-36)
5. If user enters characters
6. Then
7. Display you must only enter interger values
8. End If
9. If user enters values outside range (0-36) less than zero, more thean 36
10. Then
11. Display you must only enter interger values within the range
12. End If
13. Randomise numbers
14. Display winning number
15. If
16. Bet number is equal to randomised number
17. Then
18. Display the user bet number, user bet amount, Calculate payout vaulue(winnings+ betamount)
19. Calculate subtotal of player net profit/loss(minus total loses for remaining three bets)
20. Else
21. Display loss
22. End
23. */
24.
25. #include <stdio.h>
26. #include <stdlib.h>
27. #include <time.h>
28. #include <string.h>
29.
30. int main (void)
31. {
32.
33. int money,betnumber,money2,betnumber2,money3,betnumber3,money4,betnumber4;
34. int loss1,loss2,loss3,loss4;
35. int winning1,winning2,winning3,winning4;
36. int randnumber;
37. int winnings, profit, loss;
38. int totalwinnings, totalbetamount, totalloss;
39. int inputresult1,inputresult2,inputresult3,inputresult4;
40. int totalinput;
41.
42. inputresult1= scanf("%d %d ",&money, &betnumber);
43. inputresult2= scanf("%d %d ",&money2, &betnumber2);
44. inputresult3= scanf("%d %d ",&money3, &betnumber3);
45. inputresult4= scanf("%d %d ",&money4, &betnumber4);
46.
47. totalinput= inputresult1+inputresult2+inputresult3+inputresult4;
48.
49. srand (time (0));
50.
51. randnumber = rand() % 37;
52.
53. printf("the ball has landed on %d\n", randnumber); /*generates a random number between 0-36*/
54.
55.  if(totalinput !=8 ) /*checks that there are 8 input values entered and displays the error message*/
56. {printf ("there must be 8 interger values\n");
57.  }
58.
59. {if(totalinput !=8 )/*if there aren't 8 interger values make values 0, therefore no calculations performed*/
60. {
61. winning1=0;
62. money=0;
63. }else if( inputresult1== 0) /* checks that interger values are entered for 1st set of numbers*/
64.
65. {
66. printf("please enter integer values for betamount and betnumber\n");
67. winning1=0;
68. money=0;
69. }else if(betnumber>36 || betnumber<0) /*checks that the betnumber is within the range 0-36*/
70. {
71. printf("for your 1st betnumber please enter a value within the range 0-36\n");
72. winning1=0;
73. money=0;
74. return 0;/*ends programme as betnumber is outside the range*/
75. }else if (betnumber==betnumber2 || betnumber==betnumber3 || betnumber==betnumber4)
76. {
77. printf("the same betnumber has been entered more than once, please have different values");
78. return 0;
79. }
80. else if (randnumber==betnumber) /*calculations performed only if you've won*/
81. {
82. printf( "You bet  £%d on number %d \n", money, betnumber);
83. printf("You've Won! your ball landed on %d\n", betnumber);
84. printf("Your Payout Value is £%d on your 1st bet\n", winning1=(money*35)+money);
85. }
86.
87. else /*calcuations performed only if you've lost*/
88. {
89. printf( "You bet  £%d on number %d \n", money, betnumber);
90. printf("You lost £%d on your 1st bet \n",money);
91. winning1=0;
92. }
93. }
94.
95. {if(totalinput !=8 )/*if there aren't 8 interger values make values 0, therefore no calculations performed*/
96. {
97. winning2=0;
98. money2=0;
99. }else if( inputresult2== 0)/* checks that interger values are entered for 2nd set of numbers*/
100.
101. {
102. printf("please enter integer values for betamount and betnumber \n");
103. winning2=0;
104. money2=0;
105.    }else if(betnumber2>36 || betnumber2<0)/*checks that the betnumber is within the range 0-36*/
106. {
107. printf("for your 2nd betnumber please enter a value within the range 0-36\n");
108. winning2=0;
109. money2=0;
110. return 0;/*ends programme as betnumber is outside the range*/
111. }else if (betnumber2==betnumber||betnumber2==betnumber3||betnumber2==betnumber4)
112. {
113. printf("the same betnumber has been entered more than once, please have different values");
114. return 0;
115. }
116. else if (randnumber==betnumber2) /*calculations performed only if you've won*/
117. {
118. printf( "You bet  £%d on number %d \n", money2, betnumber2);
119. printf("You've Won! your ball landed on %d\n", betnumber2);
120. printf("Your Payout Value is £%d on your 2nd bet\n", winning2=(money2*35)+money2);
121. }
122.
123. else /*calcuations performed only if you've lost*/
124. {
125. printf( "You bet  £%d on number %d \n", money2, betnumber2);
126. printf("You lost £%d on your 2nd bet \n",money2);
127. winning2=0;
128. }
129. }
130.
131. {
132. if(totalinput !=8 )/*if there aren't 8 interger values make values 0, therefore no calculations performed*/
133. {
134. winning3=0;
135. money3=0;
136. }else if( inputresult3== 0)/* checks that interger values are entered for 3rd set of numbers*/
137.
138. {
139. printf("please enter integer values for betamount and betnumber \n");
140. winning3=0;
141. money3=0;
142.    }else if(betnumber3>36 || betnumber3<0)/*checks that the betnumber is within the range 0-36*/
143.
144. {
145. printf("for your 3rd betnumber please enter a value within the range 0-36\n");
146. winning3=0;
147. money3=0;
148. return 0;/*ends programme as betnumber is outside the range*/
149. }else if (betnumber3==betnumber2||betnumber3==betnumber||betnumber3==betnumber4)
150. {
151. printf("the same betnumber has been entered more than once, please have different values");
152. return 0;
153. }
154. else if (randnumber==betnumber3)/*calculations performed only if you've won*/
155. {
156. printf( "You bet  £%d on number %d \n", money3, betnumber3);
157. printf("You've Won! your ball landed on %d\n", betnumber3);
158. printf("Your Payout Value is £%d on your 3rd bet\n", winning3=(money3*35)+money3);
159. }
160.
161. else/*calcuations performed only if you've lost*/
162. {
163. printf( "You bet  £%d on number %d \n", money3, betnumber3);
164. printf("You lost £%d on your 3rd bet \n",money3);
165. winning3=0;
166. }
167. }
168.
169. {if(totalinput !=8 )/*if there aren't 8 interger values make values 0, therefore no calculations performed*/
170. {
171. winning4=0;
172. money4=0;
173. }else if( inputresult4== 0)/* checks that interger values are entered for 4th set of numbers*/
174.
175. {
176. printf("please enter integer values for betamount and betnumber \n");
177. winning4=0;
178. money4=0;
179.    }else if(betnumber4>36 || betnumber4<0)/*checks that the betnumber is within the range 0-36*/
180.
181. {
182. printf("for your 4th betnumber please enter a value within the range 0-36\n");
183. winning4=0;
184. money4=0;
185. return 0;/*ends programme as betnumber is outside the range*/
186. }else if (betnumber4==betnumber2||betnumber4==betnumber3||betnumber4==betnumber)
187. {
188. printf("the same betnumber has been entered more than once, please have different values");
189. return 0;
190. }
191. else if (randnumber==betnumber4)/*calculations performed only if you've won*/
192. {
193. printf( "You bet  £%d on number %d \n", money4, betnumber4);
194. printf("You've Won! your ball landed on %d\n", betnumber4);
195. printf("Your Payout Value is £%d on your 4th bet\n", winning4=(money4*35)+money4);
196. }
197.
198. else/*calcuations performed only if you've lost*/
199. {
200. printf( "You bet  £%d on number %d \n", money4, betnumber4);
201. printf("You lost £%d on your 4th bet \n",money4);
202. winning4=0;
203. }
204. }
205.
206. totalbetamount=money+money2+money3+money4;/*total loss is equal to all the money you've bet*/
207. totalwinnings=winning1+winning2+winning3+winning4;
208.
209.
210. if (totalwinnings>totalbetamount) /*calculation to determine if you have a profit or loss*/
211. {
212. printf("You have placed a total of £%d on all four bets\n", totalbetamount);
213. printf("You have a totalwinnings of £%d\n", totalwinnings);
214. printf("You have a profit of £%d \n", totalwinnings-totalbetamount);
215.
216. }
217.
218. else
219. {
220. printf("You have a Loss of £%d\n", totalbetamount);
221. }
222.
223. }