<mosaic.cnfolio.com>
PROGRAM
1. /* START
2. Enter four numbers for your bets and money
3. Wait for the wheel to spin
4. When the wheel lands on a number
5. Display the bet number
6. Display the bet amount
7. Display the winning bet number
8.
9. IF
10. Any of your bets is equal to that number
11. THEN
12. You gain the bet amount multiplied by 35
13. ELSE
14. You lose all the money you bet
15.
16. IF
17. The user enters less than 4 bet numbers or amount
18. THEN
19. Display an error message which would ask for four bet inputs and four bet amounts
20.
21. END IF
22. An error message must check for negative inputs and alphabets and inputs higher than 36
23.
24. Display Net profit
25. Display Net losses
26.
27. IF
28. The user wants to be bet on colors which include red and black and green
29. THEN
30. END IF
31. The user can bet on the red black or green number that would land
32. IF
33. The user wins a color bet
34. THEN
35. The bet amount is multiplied by two
36. END IF
37. Display final pocket value
38. END
39.
40. */
41.
42.
43.
44.
45.
46.
47. #include<stdio.h>
48. #include<stdlib.h>
49. #include<time.h>
50. #include<string.h>
51.
52.
53. int main(void)
54.
55. {
56.
57. int Money1=0;//Bet amount paid by the Player//
58. int Bet1=37;//Bet number entered by the Player//
59.
60. int Money2=0;
61. int Bet2=37;
62.
63. int Money3=0;
64. int Bet3=37;
65.
66. int Money4=0;
67. int Bet4=37;
68.
69. int Losses1=0;//The loses of the player//
70.
71. int Losses2=0;
72.
73. int Losses3=0;
74.
75. int Losses4=0;
76.
77. int TotalLosses=0;//The total loses of the Player
78.
79. int Profits1=0;//The Profits acquired by the player//
80.
81. int Profits2=0;
82.
83. int Profits3=0;
84.
85. int Profits4=0;
86.
87. int TotalProfits=0;//The total Profits acquired by the player//
88. int Payoutvalue1=0;
89. int Payoutvalue2=0;
90. int Payoutvalue3=0;
91. int Payoutvalue4=0;
92. int R;//The random number defined here//
93.
94. char Bet1a;//Defining the Bets as strings to compare them later with the main bets//
95. char Bet2a;
96. char Bet3a;
97. char Bet4a;
98. char dz[]="00";//Defining double zero as a character dz//
99. int other;//Other is defined just to ask the player if he/she wants to bet on red or black//
100. int other1=0;//Other1 is defined for RED bets//
101. int other2=0;//Other2 is defined for BLACK bets//
102.
103.
104.
105. scanf("%s",&Bet1a);
106. scanf("%d",&Money1);
107. scanf("%s",&Bet2a);
108. scanf("%d",&Money2);
109. scanf("%s",&Bet3a);
110. scanf("%d",&Money3);
111. scanf("%s",&Bet4a);
112. scanf("%d",&Money4);
113.
114. printf("Please enter the 4 bets and the money for each bet");
115.
116. if(strncmp(dz,Bet1a,2))//Comparing characters of both strings and then changing alphabets to integers with "2" meaning the 00 implemented as two characters"
117. {Bet1=atoi(Bet1a);}
118.
119. if(strncmp(dz,Bet2a,2))
120. {Bet2=atoi(Bet2a);}
121.
122. if(strncmp(dz,Bet3a,2))
123. {Bet3=atoi(Bet3a);}
124.
125. if(strncmp(dz,Bet4a,2))
126. {Bet4=atoi(Bet4a);}
127.
128. if((Bet1<0)||(Bet2<0)||(Bet3<0)||(Bet4<0)||(Bet1>37)||(Bet2>37)||(Bet3>37)||(Bet4>37))//The condition for which if the inputs are less than 0 or more than 37 it would ask you to input a number more than or equal to 0 and less than or equal to 36//
129.
130. {
131. printf("\nERROR!,Please enter 4 numbers for the bets and 4 for the bet amounts\nnumbers between 00-36\n");
132. exit(0);
133. }
134.
135. if((Money1<=0)||(Money2<=0)||(Money3<=0)||(Money4<=0))//The condition if the money is less than or equal to 0 then and error would happen because an amount has to be entered which should be more than 0//
136. {
137. printf("\nERROR!,Please enter a positive amount for the money\nPlease enter 4 number for the bets and 4 for the bet amounts\n");
138. exit(0);
139. }
140.
141.
142.
143. srand(time(NULL));//initialise the number generator randomiser//
144. R = rand()%38;//Calls a random number between 0-38//
145.
146.
147. if (R==37)//IF 37 is the random then it is equal to 00//
148. {
149. printf("\nThe winning number is 00\n");
150. }
151. else
152. {
153. printf("\nThe winning number is %d\n",R);
154. }
155. if(Bet1==R)
156. {Profits1=(Money1*35);
157. Payoutvalue1 = Money1*36;//The profit plus your own bet//
158. printf("\nCongrats! Bet1 is the winner! %d\n",Profits1);
159. Losses1 =Money1*1;
160. printf("\nProfits are \$%d\n",Profits1);
161. printf("\nLosses are \$%d\n",Losses1);
162. printf("\nPayout value is \$%d\n",Payoutvalue1);
163. }
164. else
165. { printf("\nUnfortunately, Bet1 didnt win\n");
166. Profits1=0;
167. Losses1 =(Money1*1);
168. printf("\nProfits are \$%d\n",Profits1);
169. printf("\nLosses are \$%d\n",Losses1);
170. printf("\nPayout value is \$%d\n",Payoutvalue1);
171. }
172.
173. if(Bet1==37)
174. {
175. printf("\nYour bet is 00\n");
176. }
177. else
178. {printf("\nYour bet is %d\n",Bet1);
179. }
180.
181. if(Bet1==37)
182. {
183. printf("\nYou bet \$%d\n",Money1);
184. }
185. else
186. {printf("\nYou bet \$%d\n",Money1);
187. }
188.
189.
190. if(Bet2==R)
191. {Profits2=(Money2*35);
192. Payoutvalue2 = Money2*36;
193. printf("\nCongrats! Bet2 is the winner! %d\n",Profits2);
194. Losses2=1*Money2;
195. printf("\nProfits are \$%d\n",Profits2);
196. printf("\nLosses are \$%d\n", Losses2);
197. printf("\nPayout value is \$%d\n",Payoutvalue2);
198. }
199.
200. else
201. { printf("\nUnfortunately, Bet2 didnt win\n");
202. Profits2=0;
203. Losses2 =(Money2*1);
204. printf("\nProfits are \$%d\n",Profits2);
205. printf("\nLosses are \$%d\n",Losses2);
206. printf("\nPayout value is \$%d\n",Payoutvalue2);
207. }
208.
209. if(Bet2==37)
210. {
211. printf("\nYour bet is 00 \n");
212. }
213. else
214. {printf("\nYour bet is %d\n",Bet2);
215. }
216. if(Bet2==37)
217. {
218. printf("\nYou bet \$%d\n",Money2);
219. }
220. else
221. {printf("\nYou bet \$%d\n",Money2);
222. }
223.
224. if(Bet3==R)
225.
226. {Profits3=(Money3*35);
227. Payoutvalue3 = Money3*36;
228.
229. printf("\nCongrats! Bet3 is the winner! %d\n",Profits3);
230.
231. Losses3=1*Money3;
232.
233. printf("\nProfits are \$%d\n",Profits3);
234. printf("\nLosses are \$%d\n", Losses3);
235. printf("\nPayout value is \$%d\n",Payoutvalue3);}
236.
237. else
238. { printf("Unfortunately, Bet3 didnt win\n");
239. Profits3=0;
240. Losses3 =(Money3*1);
241. printf("\nProfits are \$%d\n",Profits3);
242. printf("\nLosses are \$%d\n",Losses3);
243. printf("\nPayout value is \$%d\n",Payoutvalue3);
244. }
245.
246. if(Bet3==37)
247. {
248. printf("\nYour bet is (00)\n");
249. }
250. else
251. {printf("\nYour bet is %d\n",Bet3);
252. }
253. if(Bet3==37)
254. {
255. printf("\nYou bet \$%d\n",Money3);
256. }
257. else
258. {printf("\nYou bet \$%d\n",Money3);
259. }
260. if(Bet4==R)
261.
262. {Profits4=(Money4*35);
263. Payoutvalue4 = Money4*36;
264.
265. printf("Congrats! Bet4 is the winner! %d\n",Profits4);
266.
267. Losses4=1*Money4;
268.
269. printf("\nProfits are \$%d\n",Profits4);
270. printf("\nLosses are \$%d\n", Losses4);
271. printf("\nPayout value \$%d\n",Payoutvalue4);}
272.
273. else
274. { printf("Unfortunately, Bet4 didnt win\n");
275. Profits4=0;
276. Losses4 =(Money4*1);
277. printf("\nProfits are \$%d\n",Profits4);
278. printf("\nLosses are \$%d\n",Losses4);
279. printf("\nPayout value \$%d\n",Payoutvalue4);
280. }
281.
282. if (Bet4==37)
283. {
284. printf("\nYour bet 00\n");
285. }
286. else
287. {printf("\nYour bet is %d\n",Bet4);
288. }
289. if(Bet4==37)
290. {
291. printf("\nYou bet \$%d\n",Money4);
292. }
293. else
294. {printf("\nYou bet \$%d\n",Money4);
295. }
296. {
297. TotalProfits = Profits1+Profits2+Profits3+Profits4;
298.
299. TotalLosses = Losses1+Losses2+Losses3+Losses4;
300. }
301. {
302. printf("The total losses are \$%d\n", TotalLosses);
303. }
304. {
305. printf("The total Profits are \$%d\n", TotalProfits);
306. }
307. if (TotalLosses<TotalProfits)
308. {
309. printf("Unfortuantely You just lost");
310. }
311. if (TotalProfits<TotalLosses)
312. {
313. printf("Congratulations You won");
314. }
315. printf("\nWould you like to bet on the red numbers or black numbers? if so enter number 1");
316. scanf("%d",&other);
317. if(other==1)//IF the player wants to bet on red and black, he/she enters number 1 proceeded by the bet number and amount for both red and black//
318. {printf("\n enter 1 for red or 1 for black followed by their amount");
319. scanf("%d",&other1);
320. scanf("%d",&other2);
321. if (R==1||3||5||7||9||12||14||16||18||19||21||23||25||27||30||32||34||36)
322. {printf("\nCongrats red won you win \$%d",other1*2);
323. }
324. else {
325. printf("\nGreen won, you lose");
326. }
327. if (R==2||4||6||8||10||1||13||15||17||20||22||24||26||28||29||31||33||35)
328.
329. {printf("\nBlack won you win \$%d",other2*2);}
330. else {
331. printf("\nGreen won, you lose");
332. }
333. }
334. }