<mosaic.cnfolio.com>
PROGRAM
1. /*
2.
3. START
4. Input the 4 bet numbers and 4 money values,
5. IF any of the bet numbers are under 0,
6. ENDIF
7. THEN display error message,
8. IF the bet number is above 36,
9. ENDIF
10. THEN display error message,
11. IF random number is equal to one of the input bet numbers,
12. ENDIF
13. THEN multiply their money value associated with their bet number by 35 and add their original input money value,
14. IF none of their input numbers is equal to the random number,
15. ENDIF
16. THEN they lose all their money balance becomes they money they bet multipled by 2 and taken away from the money thet initially bet.
17. DISPLAY final money loss/profit
18.
19. END
20.
21. */
22.
23.
24.
25.
26.
27. #include <stdio.h>
28. #include <stdlib.h>
29. #include <time.h>
30.
31.
32. int main(void)
33. {
34.
35.   int number, result, bet1=37, bet2=37, bet3=37, bet4=37, MonAmounta, MonAmountb, MonAmountc, MonAmountd, check=0, ProfitMADE, Profitlossa, Profitlossb, Profitlossc, Profitlossd;
36.   char beta, betb, betc, betd, extra[]="00";
37.
38.   scanf("%s %d %s %d %s %d %s %d", &beta, &MonAmounta, &betb, &MonAmountb, &betc, &MonAmountc, &betd, &MonAmountd);
39.
40.   if (strcmp (extra, beta, 2)){
41.       bet1=atoi(beta);}
42.   if (strcmp (extra, betb, 2)){
43.       bet2=atoi(betb);}
44.   if (strcmp (extra, betc, 2)){
45.       bet3=atoi(betc);}
46.   if (strcmp (extra, betd, 2)){
47.       bet4=atoi(betd);}
48.
49.   if (bet1 >=0 && bet1 <= 37 && bet2 >=0 && bet2 <=37 && bet3>=0 && bet3<=37 && bet4>=0 && bet4<=37)
50.
51.    srand( time( 0 ) );
52.    number =( rand() % 38);
53.   if(number==37) {
54.   printf("\n\nThe winning number is 00\n");}
55.    else { printf( "\nThe winning number is %d\n", number );}
56.
57.   if(bet1<0) {
58.   printf("Error:\n Your First bet number is invalid.\n Number must be between 0 and 36\n\n"); check==1;}
59.   if(bet2<0) {
60.   printf("Error:\n Your Second bet number is invalid.\n Number must be between 0 and 36\n\n"); check==1;}
61.   if(bet3<0) {
62.   printf("Error:\n Your Third bet number is invalid.\n Number must be between 0 and 36\n\n"); check==1;}
63.   if(bet4<0) {
64.   printf("Error:\n Your Fourth bet number is invalid.\n Number must be between 0 and 36\n\n"); check==1;}
65.
66.   if(bet1>37) {
67.   printf("Error:\n Your First bet number is invalid.\n Number must be between 0 and 36\n\n"); check==1;}
68.   if(bet2>37) {
69.   printf("Error:\n Your Second bet number is invalid.\n Number must be between 0 and 36\n\n"); check==1;}
70.   if(bet3>37) {
71.   printf("Error:\n Your Third bet number is invalid.\n Number must be between 0 and 36\n\n"); check==1;}
72.   if(bet4>37) {
73.   printf("Error:\n Your Fourth bet number is invalid.\n Number must be between 0 and 36\n\n"); check==1;}
74.
75.    printf( "\nYour bet number was %s\n The amount of money you bet was £%d", beta, MonAmounta);
76.   if((number != bet1)){
77.   printf("\nYou have lost £%d sorry!\n\n", (Profitlossa=MonAmounta));check==1;}
78.   printf( "Your bet number was %s\n The amount of money you bet was £%d", betb, MonAmountb);
79.   if((number != bet2)){
80.   printf("\nYou have lost £%d sorry!\n\n", (Profitlossb=MonAmountb));check==1;}
81.   printf( "Your bet number was %s\n The amount of money you bet was £%d", betc, MonAmountc);
82.   if((number != bet3)){
83.   printf("\nYou have lost £%d sorry!\n\n", (Profitlossc=MonAmountc));check==1;}
84.   printf( "Your bet number was %s\n The amount of money you bet was £%d", betd, MonAmountd);
85.   if((number != bet4)){
86.   printf("\nYou have lost £%d sorry!\n\n", (Profitlossd=MonAmountd));check==1;}
87.
88.   if((number==bet1)) {
89.   printf("\nCongratulations!\n You now have £%d\n", ProfitMADE=(MonAmounta*35+MonAmounta));}
90.   if((number==bet2)) {
91.   printf("\nCongratulations!\n You now have £%d\n", ProfitMADE=(MonAmountb*35+MonAmountb));}
92.   if((number==bet3)) {
93.   printf("\nCongratulations!\n You now have £%d\n", ProfitMADE=(MonAmountc*35+MonAmountc));}
94.   if((number==bet4)) {
95.   printf("\nCongratulations!\n You now have £%d\n", ProfitMADE=(MonAmountd*35+MonAmountd));}
96.
97.   printf("\n\nYour total money Profit is £%d\n",ProfitMADE);
98.   printf("\nYour total money Loss is £%d\n",(Profitlossa+Profitlossb+Profitlossc+Profitlossd));
99.     }