<mosaic.cnfolio.com>
PROGRAM
1. /*START
2.   Obtain the four numbers that is being bet on
3.   Obtain the four diffrent bet amount for each bet
4.   IF the number being bet on is less than 0 or larger than 37
5.      THEN display the error message
6.   IF the be amount is less than or equal to 0
7.      THEN Display the error message
8.   END IF
9.   Spin the wheel
10.   IF the number being bet on is equal to the winning number
11.   THEN display the winning bet
12.   Display the bet amount
13.     Multiply 36 to the bet amount
14.       Display the payout
15.         Display the netpofit
16.           Calculate the total profit and add to wallet value
17.   ELSE
18.           Display the winning nunmber
19.         Display payout as 0
20.       Display net profit as 0
21.     Calculate the netloss
22.   Deduct the all four bet amounts from the wallet
23.   END IF
24. END*/
25.
26.
27. #include <stdio.h>
28. #include <stdlib.h>
29. #include <time.h>
30. #include <string.h>
31.
32. int main(void)
33. {
34. int bet1=37;
35. int bet2=37;
36. int bet3=37;
37. int bet4=37;
38.
39. int winning1=0;
40. int losing1=0;
41. int winning2=0;
42. int losing2=0;
43. int winning3=0;
44. int losing3=0;
45. int winning4=0;
46. int losing4=0;
47.
48. int amount1=0;
49. int amount2=0;
50. int amount3=0;
51. int amount4=0;
52.
53. int blandNo;                                               //The winning number.
54. int netprofit=0;
55. int netloss=0;
56.
57. char number1[2];
58. char number2[2];
59. char number3[2];
60. char number4[2];
61. char doubleZero[]="00";
62.
63. scanf("%s %d", &number1, &amount1);
64. scanf("%s %d", &number2, &amount2);
65. scanf("%s %d", &number3, &amount3);
66. scanf("%s %d", &number4, &amount4);
67.
68. if(strncmp(doubleZero,number1,2))    /*It compares the two strings and if the statement is true then, it converts alphabate to integer*/
69.    bet1=atoi(number1);
70. if(strncmp(doubleZero,number2,2))
71.    bet2=atoi(number2);
72. if(strncmp(doubleZero,number3,2))
73.    bet3=atoi(number3);
74. if(strncmp(doubleZero,number4,2))
75.    bet4=atoi(number4);
76.
77. if((bet1<0)||(bet2<0)||(bet3<0)||(bet4<0)||(bet1>37)||(bet2>37)||(bet3>37)||(bet4>37))
78.    {
79.    printf("ERROR: Please insert the input value between 0 to 37 or 8 imputs value.");
80.    exit(0);                          /*I chose to use it because I found it shorter and easier in contrast to 'if statement'*/
81.    }
82. if((amount1<=0)||(amount2<=0)||(amount3<=0)||(amount4<=0))
83.    {
84.    printf("ERROR: Please place the bet amount larger than 0 or 8 inputs value.");
85.    exit(0);
86.    }
87. srand(time(NULL));                                        // It initialise the random number generator.
88.
89. blandNo=rand()%38;
90.
91. if(blandNo==37)
92.    {
93.    printf("Congratulation,the winner is 00\n");
94.    }
95.   else
96.    {
97.    printf("Congratulation, the winner is %d\n", blandNo); // It displays the winning number.
98.    }
99.
100. if(bet1==blandNo)
101.    {
102.    winning1=amount1*36;                                   //It gives you the payout value for each bet.
103.    printf("\nYour total payout is \$%d\n", winning1);
104.    netprofit=netprofit+amount1*35;                        //It calculates the netprofit for each bet.
105.    losing1=1*amount1;
106.    }
107. else
108.    {
109.    losing1=1*amount1;                                     //It gives the netloss value for each bet.
110.    winning1=0;
111.    printf("\nThe loss from bet1 is \$%d\n", losing1);
112.    printf("Your payout value is \$%d\n", winning1);
113.    netloss=netloss+losing1;
114.    }
115.
116. if(bet1==37)                                                     // This statement is to display the number being bet on.
117.    {
118.    printf("The number you bet on is 00\n");
119.    }
120. else
121.    {
122.    printf("The number you bet on is %d\n", bet1);
123.    }
124. if(bet1==37)                                                    // This statement is to display the bet amount.
125.    {
126.    printf("Your bet amount is \$%d\n", amount1);
127.    }
128. else
129.    {
130.    printf("Your bet amount is \$%d\n", amount1);
131.    }
132. if(bet2==blandNo)
133.    {
134.    winning2=amount2*36;
135.    printf("\nYour total payout is \$%d\n", winning2);
136.    netprofit=netprofit+amount2*35;
137.    losing2=1*amount2;
138.    }
139. else
140.    {
141.    losing2=1*amount2;
142.    winning2=0;
143.    printf("\nThe loss from bet2 is \$%d\n", losing2);
144.    printf("Your payout is value is \$%d\n", winning2);
145.    netloss=netloss+losing2;
146.    }
147.
148. if(bet2==37)
149.    {
150.    printf("The number you bet on is 00\n");
151.    }
152. else
153.    {
154.    printf("The number you bet on is %d\n", bet2);
155.    }
156. if(bet2==37)
157.    {
158.    printf("Your bet amount is \$%d\n", amount2);
159.    }
160. else
161.    {
162.    printf("Your bet amount is \$%d\n", amount2);
163.    }
164. if(bet3==blandNo)
165.    {
166.    winning3=amount3*36;
167.    printf("\nYour total payout is \$%d\n", winning3);
168.    netprofit=netprofit+amount3*35;
169.    losing3=1*amount3;
170.    }
171. else
172.    {
173.    losing3=1*amount3;
174.    winning3=0;
175.    printf("\nThe loss from bet3 is \$%d\n", losing3);
176.    printf("Your payout value is \$%d\n", winning3);
177.    netloss=netloss+losing3;
178.    }
179.
180. if(bet3==37)
181.    {
182.    printf("The number you bet on is 00\n");
183.    }
184. else
185.    {
186.    printf("The number you bet on %d\n", bet3);
187.    }
188. if(bet3==37)
189.    {
190.    printf("Your bet amount is \$%d\n", amount3);
191.    }
192. else
193.    {
194.    printf("Your bet amount is \$%d\n", amount3);
195.    }
196. if(bet4==blandNo)
197.    {
198.    winning4=amount4*36;
199.    printf("\nYour total payout is \$%d\n", winning4);
200.    netprofit=netprofit+amount4*35;
201.    losing4=1*amount4;
202.    }
203. else
204.    {
205.    losing4=1*amount4;
206.    winning4=0;
207.    printf("\nThe loss from bet4 is \$%d\n", losing4);
208.    printf("Your payout value is \$%d", winning4);
209.    netloss=netloss+losing4;
210.    }
211.
212. if(bet4==37)
213.    {
214.    printf("The number you bet on is is 00\n");
215.    }
216. else
217.    {
218.    printf("The number you bet on is %d\n", bet4);
219.    }
220. if(bet4==37)
221.    {
222.    printf("Your bet amount is \$%d\n", amount4);
223.    }
224. else
225.    {
226.    printf("Your bet amount is \$%d\n", amount4);
227.    }
228.
229. printf("\nThe Netprofit is \$%d\n", netprofit);                              // It displays the total netprofit.
230. printf("\nThe Netloss is \$%d\n", netloss);                                  // It displays the total netloss.
231. printf("\nModification to the wallet amount is \$%d\n", netprofit-netloss)// It shows the changes in your wallet.
232.
233. }