<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START:
  3.  
  4. Input the four bets and values for each
  5. We are using the american style roullette
  6. display the betting number
  7. display the amount of for the bet
  8. display the winning  number
  9. If betting number equals the generated winning number
  10.   THEN
  11.   multiply the winning value by 35 to calculate the profit
  12.   ELSE
  13.    subtract the amount given
  14. END if
  15. If number of inputs is less then 8 inputs
  16.    display erorr message
  17. END If
  18. If money value enterd is a negative value
  19.    display error message
  20. End if
  21. If bet value is less the 0 or more than 37
  22.    display error message
  23. END if
  24. If bet won
  25.    display total profit at the end
  26. End if
  27. If bet lost
  28.    display total loss at the end
  29. End if
  30.    
  31.    END
  32.    
  33. */
  34.  
  35.  
  36. #include <stdio.h>
  37. #include <stdlib.h>
  38. #include <time.h>
  39. #include <string.h>
  40. int main (void)
  41. {
  42. // amount is the money paid
  43. int amount1=0;
  44. int amount2=0;
  45. int amount3=0;
  46. int amount4=0;
  47. // betting is the number chosen
  48. int betting1=37;
  49. int betting2=37;
  50. int betting3=37;
  51. int betting4=37;
  52. // earnings is the money you win
  53. int earning1 =0;
  54. int earning2=0;
  55. int earning3=0;
  56. int earning4=0;
  57. // money loss is the money you lost
  58. int moneyloss1=0;
  59. int moneyloss2=0;
  60. int moneyloss3=0;
  61. int moneyloss4=0;
  62. // g stands for gambling which will generate a random number which acts as the wheel
  63. int g;
  64. // total earning is your profit if you number is choosen
  65. int totalearning;
  66. // the money you lost
  67. int totalmoneyloss;
  68.  
  69. char Betting1[2];
  70. char Betting2[2];
  71. char Betting3[2];
  72. char Betting4[2];
  73. char doublez[]="00";
  74.  
  75. // the begening of the program
  76. printf("hello and welcome to the all american casino here in london\n please enter the bets followed by the price maximum of 4 allowed\n");
  77. // the scan f's are for inputing you 4 bets and the money
  78. scanf("%s",&Betting1);
  79. scanf("%d",&amount1);
  80. scanf("%s",&Betting2);
  81. scanf("%d",&amount2);
  82. scanf("%s",&Betting3);
  83. scanf("%d",&amount3);
  84. scanf("%s",&Betting4);
  85. scanf("%d",&amount4);
  86. // this is the string comparrison which compares the alphabet to integer
  87. if(strncmp(doublez,Betting1,2))
  88. {betting1=atoi(Betting1);}
  89.  
  90. if(strncmp(doublez,Betting2,2))
  91. {betting2=atoi(Betting2);}
  92.  
  93. if(strncmp(doublez,Betting3,2))
  94. {betting3=atoi(Betting3);}
  95.  
  96. if(strncmp(doublez,Betting4,2))
  97. {betting4=atoi(Betting4);}
  98. // this is to generate a random number
  99. srand(time(0));
  100. g = rand()%38;
  101. // this is to display the error code
  102. if( (betting1<0)||(amount1<=0)||(betting1>37) ||(betting2<0)||((amount2<=0)||(betting2>37) ||(betting3<0)||(amount3<=0)||(betting3>37) ||(betting4<0)||(amount4<=0)||(betting4>37)) )
  103. {
  104. printf("\nError! sorry you can not bet with zero or less please incerese betting amount or bet number 00 or 0-36.\n");
  105. exit(0);
  106. }
  107. // this is to change number 37 to act as 00
  108. if (g==37)
  109. {
  110. printf ("\nthe winning number is 00\n");
  111. }
  112. else
  113. {
  114. printf("\nthe winning number is %d\n",g);
  115. }
  116. // the if statment to see if bet 1 has won or lost
  117. if(betting1==g)
  118. {earning1=(amount1*35);// formula for winning bet
  119. printf("\nyour first bet is a winner %d\n",earning1);// if bet one is the winner
  120. moneyloss1=1*amount1; // formula for the loss bet
  121. printf("\nyour profit is %d\n",earning1);// if you have a profit
  122. printf("\nloss is %d\n",moneyloss1);// if you have a loss
  123. }
  124. else
  125. {
  126. printf("\nyour first bet has lost\n");
  127. moneyloss1=1*amount1;
  128. printf("\nyour profit is %d \n",earning1);
  129. printf("\nyou lost %d\n",moneyloss1);
  130. }
  131. if (betting1==37)
  132. {
  133. printf("\nthe bet is 00\n");
  134. }
  135. else
  136. {
  137. printf("\nthe bet is %d\n", betting1);
  138. }
  139. if(betting1==37)
  140. {
  141. printf("\nthe bet amount is is %d\n", amount1);
  142. }
  143. else
  144. {
  145. printf("\nthe bet amount is  %d\n", amount1);
  146. }
  147. if(betting2==g)
  148. {earning2=(amount2*35);
  149. printf("\nyour second bet is a winner %d\n",earning2);
  150. moneyloss2=1*amount2;
  151. printf("\nyour profit is %d\n",earning2);
  152. printf("\nloss is %d\n",moneyloss2);}
  153.  else
  154. {
  155. printf("\nyour second bet has lost\n");
  156. moneyloss2=1*amount2;
  157. printf("\nyour profit is %d \n",earning2);
  158. printf("\nyou lost %d\n",moneyloss2);
  159. }
  160. if (betting2==37)
  161. {
  162. printf("\nthe bet is 00\n");
  163. }
  164. else
  165. {
  166. printf("\nthe bet is %d\n", betting2);
  167. }
  168. if(betting2==37)
  169. {
  170. printf("\nthe bet amount is is %d\n", amount2);
  171. }
  172. else
  173. {
  174. printf("\nthe bet amount is is %d\n", amount2);
  175. }
  176. if(betting3==g)
  177. {earning3=(amount3*35);
  178. printf("\nyour third bet is a winner!! %d\n",earning3);
  179. moneyloss3=1*amount3;
  180. printf("\nyour profit is %d \n",earning3);
  181. printf("\nloss is %d\n",moneyloss3);}
  182.  else
  183. {
  184. printf("\nyour third bet has lost\n");
  185. moneyloss3=1*amount3;
  186. printf("\nyour profit is %d \n",earning3);
  187. printf("\nyou lost %d\n",moneyloss3);
  188. }
  189. if (betting3==37)
  190. {
  191. printf("\nthe bet is 00\n");
  192. }
  193. else
  194. {
  195. printf("\nthe bet is %d\n", betting3);
  196. }
  197. if(betting3==37)
  198. {
  199. printf("\nthe bet amount is is %d\n", amount1);
  200. }
  201. else
  202. {
  203. printf("\nthe bet amount is  %d\n", amount1);
  204. }
  205. if(betting4==g)
  206. {earning4=(amount4*35);
  207. printf("\nyour fourth bet is a winner!! %d\n",earning4);
  208. moneyloss4=1*amount4;
  209. printf("\nyour profit is %d \n",earning4);
  210. printf("\nloss is %d",moneyloss4);}
  211.  else
  212. {
  213. printf("\nyour fourth bet has lost\n");
  214. moneyloss4=1*amount4;
  215. printf("\nyour profit is %d \n",earning4);
  216. printf("\nyou lost %d\n",moneyloss4);
  217. }
  218. if (betting4==37)
  219. {
  220. printf("\nthe bet is 00\n");
  221. }
  222. else
  223. {
  224. printf("\nthe bet is %d\n", betting4);
  225. }
  226. if(betting4==37)
  227. {
  228. printf("\nthe bet amount is is %d\n", amount4);
  229. }
  230. else
  231. {
  232. printf("\nthe bet amount is  %d\n", amount4);
  233. }
  234. totalearning=earning1+earning2+earning3+earning4;// this is your total earning of 4 bets
  235. totalmoneyloss=totalearning-(amount1+amount2+amount3+amount4);//this is your total losses for 4 bets
  236.  
  237. printf("\nyour full earning and losses %d\n",totalmoneyloss);
  238.  
  239. }