<mosaic.cnfolio.com>
PROGRAM
1. /*PSEUDO CODE
2. START
3.
4. Set the bet counter = 0
5. Set payout = 0
6. Set total profit / loss = 0
7. Set subtotal profit / loss = 0
8. Get the bet numbers
9. Get the bet amounts
10. Display Welcome message
11.
12. WHILE checking for errors
13.      IF numbers needed are not equal with 8 (4 bet numbers) and (4 bet amount)
14.       THEN
15.          Display Error showing that you need 8 numbers
16.      END IF
17.          ELSE
18.             IF bet number and bet amount are not between 0 - 37 . 37 is representing 00.
19.              THEN
20.                 Display Bet number error.
21.             END IF
22.                  ELSE
23.                     IF bet amount less than 0
24.                      THEN
25.                         Display Bet amount error
26.                     END IF
27.
28. END WHILE
29.          WHILE spinning the roulette 4 times
30.            THEN
31.               DECLARING the winning number that will show numbers in a sequential order between 0 to 37. Considering 37 is 00
32.                   IF bet number is equal with the the winning number from the roulette
33.                    THEN
34.                       Payout is the money you're winning plus the amount of money you've betted
35.                       Multiply the bet amount with 35
36.                       Display Winning message
37.                       Display the bet number
38.                       Display bet amount
39.                       Display winning number
40.                       Display money won this game
41.                       Display payout value
42.                       Display subtotal net profit
43.                       Display Extra--> the colour of the number from the table
44.                        IF the bet number can be devided by 2 it means that is on BLACK
45.                         THEN
46.                            Display your bet number is on BLACK
47.                       END IF
48.                            ELSE
49.                               IF bet number is 0 or 37
50.                                THEN
51.                                   Display number bet is on GREEN
52.                               END IF
53.                                    ELSE
54.                                       IF
55.                                        Display bet number is on RED
56.                                       END IF
57.
58.                    ELSE
59.                        Substract the bet amount you've betted
60.                        Display Losser message
61.                        Display the bet number
62.                        Display bet amount
63.                        Display winning number
64.                        Display money lost this game
65.                        Display payout value
66.                        Display subtotal net loss
67.                        Display Extra--> the colour of the number from the table
68.                         IF the bet number can be devided by 2 it means that is on BLACK
69.                          THEN
70.                            Display your bet number is on BLACK
71.                         END IF
72.                              ELSE
73.                                 IF bet number is 0 or 37
74.                                  THEN
75.                                     Display number bet is on GREEN
76.                                 END IF
77.                                      ELSE
78.                                         IF
79.                                          Display bet number is on RED
80.                                         END IF
81.                  END IF
82.
83.           END WHILE
84.
85.        Display total profit/loss
86.        Display message of end game
87.
88. END
89. */
90. #include <stdio.h>
91. #include <stdlib.h>
92. #include <time.h>
93.
94.
95. int main (void)
96.
97. {
98.
99.
100. int i=0; /*bet counter*/
101. int bets[4][2]; /*two dimensional array used for creating 4 pairs (the number bet and amount money) representing the 8 inputs*/
102. int numberVar;  /*Has to be equal with 8 in order the simultion to start*/
103. int totalProfitOrLoss=0;
104. int SubTotalProfitOrLoss=0;
105. int randomNumber;
106. int Payout=0;
107. srand (time(0))/*Gives the random function a new seed, a starting point*/
108.
109. /*two dimensional array used to represent the bet number and bet amount*/
110. numberVar=scanf("%d %d %d %d %d %d %d %d",&bets[0][0],&bets[0][1],&bets[1][0],&bets[1][1],&bets[2][0],&bets[2][1],&bets[3][0],&bets[3][1]);
111.
112. printf("-----//***WELCOME TO AMERICAN ROULETTE***//----- \n");
113. printf("-----//*********SINGLE NUMBER*********//----- \n\n\n");
114.
115.
116.  for (int i=0;  i<4;i++) /*checking for errors) */
117.
118.  {
119.
120.     if (numberVar != 8) /*Checking for missing inputs*/
121.         {
122.          printf("Oops something went wrong :(\n\n ");
123.          printf("Please enter 8 inputs !!! \n");
124.          exit(1)/*exit */
125.         }
126.
127.         else if  (bets[i][0] < 0 || bets[i][0] > 37 ) /*Checking for bet number input errors*/
128.           {
129.            printf("Oops something went wrong :(\n\n ");
130.            printf("Please enter the bet numbers between 0 to 37 ---> 37 considered 00 \n");
131.            exit(1)/*exit */
132.           }
133.
134.               else if (bets[i][1] < 1 ) /*Checking for bet amount input errors*/
135.               {
136.                printf("Oops something went wrong :(\n\n ");
137.                printf("The bet amount should be higher than 0");
138.                exit(1)/*exit */
139.               }
140.   }
141.
142.    for (int i=0;  i<4;i++) /*Spinning the wheel 4 times*/
143.
144.         {
145.
146.          randomNumber = rand() % 38; /*Random number in a sequential order between 0 - 37. 37 is considered to be 00 */
147.          bets[i][0]; /*first colomn represented by zero are the bet numbers*/
148.          bets[i][1]; /*second colomn represented by one are the amount of money */
149.
150.
151.
152.            if (bets[i][0] == randomNumber) /*Checks if player won or lost their bet*/
153.
154.              {
155.                Payout = bets[i][1] * 35 + bets[i][1]; /*The money you're winning will be added with the amount of money you've betted*/
156.                SubTotalProfitOrLoss +=  bets[i][1] * 35 + bets[i][1] ; /*Subtotal profit games played */
157.                totalProfitOrLoss =  SubTotalProfitOrLoss ; /*Total Profit or Loss after all 4 bets*/
158.                    printf("*********BET NUMBER %d*********\n\n",i + 1); /* Bet counter . For each bet it will gonna add 1 */
159.                    printf("Bet Number : %d\n",bets[i][0]);    /* Printing your number*/
160.                    printf("Bet Amount : \$%d\n",bets[i][1]);   /* Printing your amount of money you've betted*/
161.                    printf("The ball landed on the number %d \n", randomNumber);/*Printing the random number*/
162.                    printf("CONGRATULATION, you've ****WON****!^_^\n"); /*Winning message */
163.                    printf("Money Won : \$%d \n ",bets[i][1] * 35 ); /*Money won is equal with the amount of money you've betted multiplied by 35  */
164.                    printf("Payout : \$%d\n",Payout ); /*The money you're winning will be added with the amount of money you've betted*/
165.                    printf("Subtotal profit \$%d\n\n", SubTotalProfitOrLoss); /*Subtotal profit from the bets you've placed */
166.
167.                   printf("EXTRA\n");/*The colour of the number from the table*/
168.
169.                    if ((bets[i][0]/2)*2 == bets[i][0]) /*IF bet number can be devided by 2 it means that is on BLACK */
170.                     {
171.                      printf("Your number you've betted is on BLACK\n\n");
172.                     }
173.                     else if (bets[i][0] == 0 || bets[i][0] == 37) /*IF number is 0 and 37 which is 00 */
174.                      {
175.                       printf("Your number you've betted is on GREEN\n\n");
176.                      }
177.
178.                      else
179.                      {
180.                       printf("Your number you've betted is on RED\n\n");
181.                      }
182.              }
183.
184.               else
185.
186.                 {
187.                   SubTotalProfitOrLoss -= bets[i][1]; /*Subtotal loss bets placed*/
188.                   totalProfitOrLoss = SubTotalProfitOrLoss; /*Total Profit or Loss after all 4 bets*/
189.                      printf("*********BET NUMBER %d*********\n\n",i + 1)/* Bet counter . For each bet it will gonna add 1 */
190.                      printf("Bet Number : %d\n",bets[i][0]);      /* Printing your number*/
191.                      printf("Bet Amount : \$%d\n",bets[i][1]);     /* Printing your amount */
192.                      printf("The ball landed on the number %d\n",randomNumber);/*Printing the random number*/
193.                      printf("BAD LUCK, you LOST! !! ^-^\n");     /*Losser message */
194.                      printf("Payout : \$0\n");
195.                      printf("Money Loss : \$%d \n ",bets[i][1]);   /*Total loss for a game */
196.                      printf("Subtotal loss \$%d\n\n", SubTotalProfitOrLoss); /*Subtotal loss from the bets you've placed */
197.
198.                    printf("EXTRA\n");/*The colour of the number from the table*/
199.
200.                    if ((bets[i][0]/2)*2 == bets[i][0])
201.                     {
202.                      printf("Your number you've betted is on BLACK\n\n");
203.
204.                     }
205.                     else if (bets[i][0] == 0 || bets[i][0] == 37)
206.                      {
207.                       printf("Your number you've betted is on GREEN\n\n");
208.                      }
209.
210.                      else
211.                      {
212.                       printf("Your number you've betted is on RED\n\n");
213.
214.                      }
215.               }
216.        }
217.
218.
219.
220.
221.       printf("TOTAL Profit/Loss overall : \$%d\n",totalProfitOrLoss); /*Total Profit or Loss*/
222.       printf("Hope to see you soon !!!\n ");
223.
224.
225. }