<mosaic.cnfolio.com>
PROGRAM
  1. #include <stdio.h>
  2.  
  3. /*
  4. START
  5. user needs to write 4 numbers for bet and 4 number for money
  6. scan 4 number for bet and 4 number for money
  7. display choose 4 numbers for the bet and 4 numbers for moeny
  8. display missing input if user write less than 8 input
  9. if
  10. the user enters less than 0 or more than 37
  11. display please write numbers between 0 to 36 also user can choose 00
  12. if
  13. the user enters the money less than 0
  14. display enter a positive number
  15. if
  16. random equal 37
  17. disapaly the winning number is 00
  18. display the money you paid for first bet is (money1)
  19. if
  20. the bet1 equal to 37
  21. display your bet is 00
  22. else
  23. display your bet is (bet1)
  24. if
  25. bet1 equal to random
  26. won1=(money1*35)
  27. bet1  won
  28. if
  29. bet1 not equal to the random
  30. won1=0
  31. loss1=money1*-1
  32. dispaly you lost
  33. ---------------------------
  34. the bet1 equal to 37
  35. display your bet is 00
  36. else
  37. display your bet is (bet2)
  38. if
  39. bet1 equal to random
  40. won1=(money2*35)
  41. bet1  won
  42. if
  43. bet1 not equal to the random
  44. won1=0
  45. loss1=money2*-1
  46. dispaly you lost
  47. ---------------------------
  48. the bet1 equal to 37
  49. display your bet is 00
  50. else
  51. display your bet is (bet3)
  52. if
  53. bet1 equal to random
  54. won1=(money3*35)
  55. bet1  won
  56. if
  57. bet1 not equal to the random
  58. won1=0
  59. loss1=money3*-1
  60. dispaly you lost
  61. -------------------------
  62. the bet1 equal to 37
  63. display your bet is 00
  64. else
  65. display your bet is (bet4)
  66. if
  67. bet1 equal to random
  68. won1=(money4*35)
  69. bet1  won
  70. if
  71. bet1 not equal to the random
  72. won1=0
  73. loss1=money4*-1
  74. dispaly you lost
  75. -----------------------
  76. totalwon = won1+won2+won3+won4
  77. display The total profit is (totalwon)
  78. totallosses = totalwon-(money1+money2+money3+money4)
  79. display The total money you get or loss (totallosses)
  80. if
  81. totallosses<=0
  82. display sorry You lose all your money
  83.  
  84.  
  85.  
  86.  
  87.  
  88. END
  89.  
  90. */
  91.  
  92.  
  93.  
  94.  
  95. #include <stdio.h>
  96. #include <stdlib.h>
  97. #include <time.h>
  98. #include <string.h>
  99.  
  100. int main( void )
  101. {
  102.  
  103. int m1=0,m2=0,m3=0,m4=0; //the bet amount
  104. int b1=37,b2=37,b3=37,b4=37;//the bet numers
  105. int loss1,loss2,loss3,loss4;//the losses amount
  106. int totallosses;//the total losses
  107. int won1,won2,won3,won4;//the wining numbers
  108. int totalwon;//the total wins
  109. int s;//the random
  110. int n;//the while for missing input
  111. char b11[2];//compare alphabets to intiger
  112. char b22[2];
  113. char b33[2];
  114. char b44[2];
  115. char z[]="00";//implemented "z" as a character to represent the double zero
  116.  
  117.  
  118. printf("choose 4 numbers for the bet and 4 numbers for money\n");//display for the user
  119.  
  120. while (8) {
  121. n=scanf("%s %d %s %d %s %d %s %d",&b11, &m1, &b22, &m2, &b33, &m3, &b44, &m4);//for missing input
  122. if (n!=8)
  123. {
  124. printf (" missing input");
  125. return;}
  126. break;}
  127.  
  128. if (strncmp(z,b11,2))//Compares the bet numbers and compares the alphabets to integers with the number "2" representing the two character in "z"
  129. {b1=atoi(b11);}
  130.  
  131. if (strncmp(z,b22,2))
  132. {b2=atoi(b22);}
  133.  
  134. if (strncmp(z,b33,2))
  135. {b3=atoi(b33);}
  136.  
  137. if (strncmp(z,b44,2))
  138. {b4=atoi(b44);}
  139.  
  140. srand(time(NULL));//Random number generator
  141. s= rand()%38;//Generates numbers between 00-38 in a specific time
  142.  
  143. if ((b1<0)||(b2<0)||(b3<0)||(b4<0)&&(b1>37)||(b2>37)||(b3>37)||(b4>37))//The condition in which the user must enter a bet more than zero and less than 37
  144. {
  145. printf ("please write numbers between 0 to 38 also you can choose 00");//print the erorr if there other input
  146. return; }
  147.  
  148. if ((m1<=0)||(m2<=0)||(m3<=0)||(m4<=0))//The condition in which the user must enter the amount of money more than zero
  149. {
  150. printf ("enter a positive number ");
  151. return; }
  152.  
  153. if (s==37)//to change the 37 to 00
  154. {
  155. printf("\nthe winning number is 00\n");
  156. }
  157. else
  158. printf("\nThe winning number is %d\n",s);
  159.  
  160. printf("\n the money you paid for first bet is %d\n",m1);
  161.  
  162.  
  163. if (b1==37)//display 00
  164. printf("\n your bet is 00\n");
  165.  
  166.  
  167. else
  168.  
  169. printf("\nyour bet is %d\n",b1);
  170.  
  171. if(b1==s)//if bet1 equal to the random
  172.  
  173. {won1=(m1*35);
  174.  
  175. printf("\n bet1  won \n");
  176.  
  177.  
  178. printf("\nthe profit is %d\n",won1);
  179.  
  180. }
  181.  
  182. if (b1!=s)//if bet1 not equal to the random
  183. {
  184. won1=0;
  185. loss1=m1*-1;
  186.  
  187. printf("\nyou lost  %d\n",loss1);
  188. }
  189.  
  190. printf("\n the money you paid for second bet is %d\n",m2);
  191.  
  192. if (b2==37)
  193. printf("\n your bet is 00\n");
  194.  
  195.  
  196. else
  197.  
  198. printf("\nyour bet is %d\n",b2);
  199.  
  200. if(b2==s)
  201.  
  202. {won2=won2+(m2*35);
  203.  
  204. printf(" \nbet2  won \n");
  205.  
  206.  
  207. printf("\nthe profit is %d\n",won2);
  208.  
  209. }
  210.  
  211. if (b2!=s)
  212.  
  213. {
  214. won2=0;
  215. loss2=m2*-1;
  216.  
  217. printf("\nyou lost  %d\n",loss2);
  218. }
  219.  
  220. printf("\n the money you paid for third bet is %d\n",m3);
  221.  
  222. if (b3==37)
  223. printf("\n your bet is 00\n");
  224.  
  225. else
  226.  
  227. printf("\nyour bet is %d\n",b3);
  228.  
  229. if(b3==s)
  230.  
  231. {won3=won3+(m3*35);
  232.  
  233. printf("\n bet3  won \n");
  234.  
  235.  
  236. printf("\nthe profit is %d\n",won3);
  237.  
  238. }
  239.  
  240. if (b3!=s)
  241. {
  242. won3=0;
  243. loss3=m3*-1;
  244.  
  245. printf("\nyou lost  %d\n",loss3);
  246. }
  247.  
  248. printf("\n the money you paid for fourth is %d\n",m4);
  249.  
  250. if (b4==37)
  251. printf("\n your bet is 00\n");
  252.  
  253. else
  254.  
  255. printf("\nyour bet is %d\n",b4);
  256.  
  257. if(b4==s)
  258.  
  259. {won4=(m4*35);
  260.  
  261. printf(" \nbet4  won \n");
  262.  
  263.  
  264. printf("\nthe profit is %d\n",won4);
  265. }
  266.  
  267. if (b4!=s)
  268. {
  269. won4=0;
  270. loss4=m4*-1;
  271.  
  272. printf("\nyou lost  %d\n",loss4);
  273. }
  274.  
  275. {
  276. totalwon = won1+won2+won3+won4;//to calculate the win numbers
  277.  
  278. }
  279.  
  280. {
  281. printf("\nThe total profit are %d\n", totalwon );
  282.  
  283. }
  284. {
  285. totallosses = totalwon-(m1+m2+m3+m4);//to calculate the losses numbers
  286. }
  287. {
  288. printf("\nThe total money you get or loss %d\n", totallosses);
  289. }
  290.  
  291. if (totallosses<=0)
  292. {
  293. printf("\nsorry You lose all your money\n");
  294. }
  295.  
  296. }