<mosaic.cnfolio.com>
PROGRAM
1. /*
2. PSUEDO CODE
3.    START
4.       generate random number
5.       IF random number is less then 37
6.          THEN display number
7.       END IF
8.       IF random number equal 37
9.          THEN display 00
10.       END IF
11.       WHILE i is equal to or between 0 and 7
12.          IF i  divided by 2 equals whole numbers
13.             THEN take the inputed chosennumber (char) that relates to that i and convert it to number (int)
14.             IF  number is less then 0
15.               THEN display "wrong number" " and stop the program
16.             END IF
17.             IF  number is greater then 36
18.               THEN display "wrong number" " and stop the program
19.             END IF
20.             IF  chosennumber and twox are the same
21.               THEN make randomno equal 37
22.             END IF
23.          END IF
24.        IF i  devide 2 does not equal whole number
25.          THEN scan wager
26.        END IF
27.        IF wager is smaller then 0
28.             THEN display "please input postitive number" and stop the program
29.        END IF
30.        IF wager is bigger then 100000000
31.             THEN display "Please input a smaller wager" and stop the program
32.        END IF
33.          END IF
35.          REPEAT
36.        END WHILE
37.        WHILE i is equal to or between 0 and 3
38.          IF random number is the same as number
39.             THEN multiplie wager by 35 and dispay wager winnings.
40.             THEN make the winngings equal same as new wager
41.        END IF
42.          IF random number is not the same
43.             THEN reduce winnings by wager and print winnings
44.        END IF
45.          IF winngins is bigger then 0
46.             THEN display total winnings of wager
47.        END IF
48.          IF winnings is less then 0
49.             THEN display lose and the total wager lost
50.        END IF
51.          IF winnging eqauls 0
52.           THEN display "breaking evening"
53.          END IF
55.        REPEAT
56.        END WHILE
57.    END
58. */
59. #include <stdio.h>
60. #include <time.h>
61. #include <string.h>
62. #include <stdlib.h>
63.
64. int main(void)
65. {
66.
67. int   randomno = 0 ;
68. int   number[4];
69. char  chosennumbers[4][6]= {"\0"};
70. char  twox[2] = {"00"} ;
71. float winnings = 0.00 ;
72. float wager[4] = {0};
73.
74.
75.
76.  srand ( time( 0 ) );
77. randomno = rand()%38;   /* make randomno = a random number bewteen 0 and 37  */
78.
79.
80.
81. if (randomno<37)                {
82.    printf( "Results %d   ", randomno );} /* if randomno is smaller than 37 print the number as the result */
83. if (randomno==37)    {
84.    printf( "Result 00   ");} /* if randomno is equal to 37 print the 00 as the result as 37 is not a number from american roulette but 00 is need instead */
85.
86.
87.
88.
89. for(int i = 0; i <=7 ; i++) /* run a loop 8 time between 0 and 7 this allows all inputs to be read */
90. {
91.
92.    if (i%2==0){   /* allows program to decide between the number and the wager */
93.       scanf("%s",&chosennumbers[i/2]);
94.     number[i/2]=atoi(chosennumbers[i/2]); /* converts the chosennumber char in a int number so allowing easy comparison */
95.
96.       if (number[i/2] <0){
97.          printf( "Please input positive chosennumber");
98.             return 0 ; /* this stops any one putting in negative number so stopping the program from break */
99.                          }
100.       if (number[i/2] >36) {
101.          printf( "Please in put a number bewteen 0-36 or 00");
102.             return 0 ; /* this stops any one putting in any number above 36 so stopping the program from break */
103.                            }
104.
105.
106.
107.       if (!strcmp(chosennumbers[i/2],twox))
108.          number[i/2] =37 ; /* compares twox to chosennumbers and so if any of them are 00 converts it to 37 for easier uses later on */
109.
110.
111.
112.            }
113.    if (i%2!=0)
114.       scanf ("%f", &wager[i/2]); /* copies wager for later uses */
115.
116.       if ( wager[i/2] <0)  {
117.          printf( "Please input postitive wager");
118.             return 0 ;     }
119.       if ( wager[i/2] >100000000)   {
120.          printf( "Please input a smaller wager");
121.             return 0 ;     }
122.
123.
124. }
125.
126. for(int i = 0; i <=3 ; i++){  /* runs a loop of 4 to allow all number to be checked if they are going to win or lose */
127.
128.
129.
130.
131.
132.    if (randomno == number[i]) {
133.       wager[i]*=35; /* wager is multiplied by 35 as these are the rule of winning in american roulette */
134.     printf("\n winnings £%0.2f  ", wager[i]);
135.     winnings+=wager[i]; /* this and line 80 adds up the winning so allowing player to know how much they have got */
136.       printf("\n subtotal £%0.2f ", winnings);
137.
138.                              }
139.
140.    if (randomno != number[i]){
141.
142.       winnings-=wager[i];
143.       printf("\nlose £%0.2f   ", wager[i]);
144.
145.
146.                              }
147.                            }
148.    if (winnings>0)                             {
149.    printf("\n total profit  £%0.2f", winnings);}
150.    if (winnings<0)                           {
151.    printf("\n total loss  £%0.2f", winnings);}
152.    if (winnings == 0)            {
153.    printf("\nbreaking evening")} /* this part is here just to show if u have lost money or gained money. */
154.
155. }