<mosaic.cnfolio.com>
PROGRAM
1. /*Pusedo code*/
2.
3.
4.
5.
6. /*
7. START
8.     READ var1, var2, var3, var4, var5, var6, var7, var8
9.     myArray[38] = { 0,28,9,26,30,11,7,20,32,17,5,22,34,15,3,24,36,13,1,00,27,10,25,29,12,8,19,31,18,6,21,33,16,4,23,35,14,2 };
10.     random generate number rand()
11.     IF if bet 1 2 3 4 win THEN
12.         = 1 and mulitpy the money value by 8
13.     ELSE
14.         0
15.     ENDIF
16.     Total = add up bet amount
17.     add up total pay out amount
18.     total payout  - total  = net profit
19.     IF if all of the input are valid  THEN
20.         WRITE The bet numbers and bet amount, winning numers, total payout and the net profit
21.     ELSE
23.     ENDIF
24. END*/
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39. #include <stdio.h>
40. #include <stdlib.h>
41. #include <time.h>
42. #include <string.h>
43.
44. int main()
45. {
46.
47. int var1, var2, var3, var4, var5, var6, var7, var8;/* odd var = bet number even var= bet value*/
48. int fpay, spay,thpay,fopay;/* fpay = payment for first bet, spay = payment for second bet*/
49.
50. int total, net, totalpay; /* total = total bet amount, net = net profit, totalpay = total payout amount */
51.
52. /* Reading input (bet number and bet amount) from user*/
53. scanf("%d", &var1);/* bet number 1*/
54. scanf("%d", &var2);/* bet amount 1*/
55. scanf("%d", &var3);/* bet number 2*/
56. scanf("%d", &var4);/* bet amount 2*/
57. scanf("%d", &var5);/* bet number 3*/
58. scanf("%d", &var6);/* bet amount 3*/
59. scanf("%d", &var7);/* bet number 4*/
60. scanf("%d", &var8);/* bet amount 4*/
61.
62.
63. /* radmon number part */
64. /*setting the timer to 0, randomize seed. Setting the timer to 0 is require to get randoms numbers.*/
65.     srand(time(0));
66. /* saving the numbers into a array*/
67. int myArray[38] = { 0,28,9,26,30,11,7,20,32,17,5,22,34,15,3,24,36,13,1,00,27,10,25,29,12,8,19,31,18,6,21,33,16,4,23,35,14,2 };
68. /*This part is for generating a random number from 1 to 38*/
69. int random1 =rand() % 38;
70. int random2 =rand() % 38;
71. int random3 =rand() % 38;
72. int random4 =rand() % 38;
73. /*random generating numbers that is from the arrry*/
74. int firstnum = myArray[random1];
75. int secondnum =myArray[random2];
76. int thirdnum = myArray[random3];
77. int forthnum = myArray[random4];
78.
79. /*first bet result check, if there is a match number, the corresponding bet amount will be mulitply by 8 else is 0*/
80.
81. if (var1 == firstnum ||var1 == secondnum  || var1 == thirdnum  || var1 == forthnum ) {
82.
83.     fpay = var2*8;
84. }
85. else {
86.
87. fpay = 0;
88. }
89.
90. /*Second bet result check*/
91. if (var3 == firstnum || var3 == secondnum  || var3 == thirdnum  || var3 == forthnum) {
92.
93.       spay = var4*8;
94.
95. }
96. else {
97.      spay = 0;
98.
99. }
100.
101. /*Third bet result check*/
102. if (var5 == firstnum || var5 == secondnum  || var5 == thirdnum  || var5 == forthnum) {
103.
104.   thpay = var6*8;
105. }
106. else {
107.     thpay = 0;
108.
109. }
110. /*forth bet  result check*/
111. if (var7 == firstnum || var7 == secondnum  || var7 == thirdnum  || var7 == forthnum) {
112.
113.    fopay = var8*8;
114. }
115. else {
116.  fopay = 0;
117.
118. }
119.
120.
121.
122.
123. /* netprofile calcuation*/
124.
125. /* calculating the total of betting money amount */
126. total = var2+var4+var6+var8;
127.
128. /*calculating the total payout amount */
129. totalpay = fpay+spay+thpay+fopay;
130.
131. /* calculating net profit */
132. net =  totalpay - total;
133.
134.
135. /* Checking is there any  unexpected or missing input values
136. bet number (var 1 3 5 7 should not be greater than 38 and smaller than 0 and var 2 4 6 8 should not be smaller the 0*/
137. if ( var1 >=0 && var1 <=38 && var3 >=0 && var3<=38 && var5 >=0 && var5<=38 && var7 >=0 && var7<=38 && var2 >0 && var4>0 && var6>0 && var8>0 ) {
138.
139.  /* displaying user bet number and bet money */
140. printf("bet number1=%2d  money amount1= %d\n", var1,var2);
141.
142. printf("bet number2=%2d  money amount2= %d\n", var3,var4);
143.
144. printf("bet number3=%2d  money amount3= %d\n", var5,var6);
145.
146. printf("bet number4=%2d  money amount4= %d\n", var7,var8);
147.
148.
149. /* displaying the winning numbers*/
150. printf("Wining numbers are %02d %02d %02d %02d\n", firstnum, secondnum, thirdnum,  forthnum);
151.
152. /* displaying the payout amount */
153. printf("Total pay out =%2d\n",totalpay);
154.
155.
156. /* net profit printout */
157. printf("net profit=%2d\n",net);
158.
159.
160. }
161.  else {
162.           /* display when there is  unexpected or missing input values*/