<mosaic.cnfolio.com>
PROGRAM
  1. /*START
  2.    Set number of bets and cash to zero
  3.    Generate random numbers to 37 using srand function
  4.    Set double zero to 37 using strings
  5.    Get bet number and bet value
  6.    Display welcome message
  7.       IF bet number is below zero and above 36 AND
  8.         bet amount is below and or equal to zero and above 500
  9.          THEN
  10.             Display error message
  11.       END IF
  12.      
  13.       IF bet number one equals winning number
  14.          THEN
  15.             Add cash bet value multiplied by 35 to cash won value
  16.             Display bet value multiplied by 35 as profit gained
  17.          ELSE
  18.             Multiply cash value by -1
  19.            Subtract cash lost value from cash bet amount
  20.           Display zero cash left value
  21.             Display cash value left
  22.       END IF
  23.      
  24.       IF bet number two equals winning number
  25.          THEN
  26.             Add cash bet value multiplied by 35 to cash won value
  27.             Display bet value multiplied by 35 as profit gained
  28.          ELSE
  29.             Multiply cash value by -1
  30.            Subtract cash lost value from cash bet amount
  31.           Display zero cash left value
  32.             Display cash value left
  33.       END IF
  34.      
  35.       IF bet number three equals winning number
  36.          THEN
  37.             Add cash bet value multiplied by 35 to cash won value
  38.             Display bet value multiplied by 35 as profit gained
  39.          ELSE
  40.             Multiply cash value by -1
  41.            Subtract cash lost value from cash bet amount
  42.           Display zero cash left value
  43.             Display cash value left
  44.       END IF
  45.      
  46.       IF bet number four equals winning number
  47.          THEN
  48.             Add cash bet value multiplied by 35 to cash won value
  49.             Display bet value multiplied by 35 as profit gained
  50.          ELSE
  51.             Multiply cash value by -1
  52.            Subtract cash lost value from cash bet amount
  53.           Display zero cash left value
  54.             Display cash value left
  55.       END IF
  56.          
  57.    Display total cash won value
  58.    Display thank you message
  59. END*/
  60.  
  61.  
  62. #include <stdio.h>
  63. #include<stdlib.h>
  64. #include<time.h>
  65. #include<string.h>
  66.  
  67.  
  68. int main()
  69. {
  70.    //Variables
  71.   int cash1=0;
  72.   int cash2=0;
  73.   int cash3=0;
  74.   int cash4=0;
  75.   int totalgainloss=0;
  76.   int gainloss1=0;
  77.   int gainloss2=0;
  78.   int gainloss3=0;
  79.   int gainloss4=0;
  80.   int cashwon1=0;
  81.   int cashwon2=0;
  82.   int cashwon3=0;
  83.   int cashwon4=0;
  84.   int totalcashwon=0;
  85.   int betno1=0;
  86.   int betno2=0;
  87.   int betno3=0;
  88.   int betno4=0;
  89.   int cashleft;
  90.   char betno1a[2];
  91.   char betno2a[2];
  92.   char betno3a[2];
  93.   char betno4a[2];
  94.   char bz[]= "00";
  95.  
  96. //Intialise to generate random number
  97. srand(time(NULL));
  98. int s = rand()%37;
  99. //
  100. if(s == 37)
  101.  { s =00;
  102.  }
  103.  
  104. if(strncmp( bz,betno1a,2))
  105. { betno1=atoi(betno1a);
  106. }
  107. if(strncmp(bz, betno2a,2))
  108. { betno2=atoi(betno2a);
  109. }
  110. if(strncmp( bz,betno3a,2))
  111. { betno3=atoi(betno3a);
  112. }
  113. if(strncmp(bz, betno4a,2))
  114. { betno4=atoi(betno4a);
  115. }
  116.  
  117. //Welcome messages, titles  and greeting
  118. printf("Hello! Welcome to this magestic casino\n");
  119. printf("       \n");
  120. printf("*******  ******   *      *  *      ****** ******* *******  ******        \n");
  121. printf("*     * *      *  *      *  *      *         *       *     *        \n");
  122. printf("******* *      *  *      *  *      *         *       *     *        \n");
  123. printf("*   *   *      *  *      *  *      ****      *       *     ****        \n");
  124. printf("*    *  *      *  *      *  *      *         *       *     *        \n");
  125. printf("*     *  ******    ******   ****** ******    *       *     ******        \n");
  126. // Ask for bet and cash inputs
  127. printf("Please enter your 4 bets and the amounts for each one\n");
  128. scanf("%d",&cash1);
  129. scanf("%d",&betno1);
  130. scanf("%d",&cash2);
  131. scanf("%d",&betno2);
  132. scanf("%d",&cash3);
  133. scanf("%d",&betno3);
  134. scanf("%d",&cash4);
  135. scanf("%d",&betno4);
  136.  
  137. //Checking to ensure the right cash and bet values are inputted
  138.  
  139. if(betno1<0||betno2<0||betno3<0||betno4<0)
  140. {printf("ERROR! Please place a valid bet\n");
  141. exit(0);
  142. }
  143.  
  144. if(betno1>37||betno2>37||betno3>37||betno4>37)
  145. {printf("ERROR! Please place a valid bet\n");
  146. exit(0);
  147. }
  148.  
  149. if(cash1<=0||cash2<=0||cash3<=0||cash4<=0)
  150. {printf("ERROR! Please can you input a positive amount of money\n");
  151. exit(0);
  152. }
  153.  
  154. if(cash1>500||cash2>500||cash3>500||cash4>500)
  155. {printf("ERROR! Please can you input below or the limited amount of money\n");
  156. exit(0);
  157. }
  158. //Instruction for the roulette game
  159. if(betno1==s)
  160. {( cashwon1 = cash1 * 35 );
  161. printf("The bet number 1 has won %d\n", cashwon1);
  162. gainloss1=(cashwon1-cash1);
  163. printf("The profit gained back is %d \n", gainloss1);
  164. }
  165.  
  166. else
  167. {printf("Sorry, the bet number 1 has lost\n");
  168. cashwon1= 0;
  169. (gainloss1=-1 * cash1);
  170. printf("You lost %d\n", gainloss1);
  171. (cashleft= cash1+ gainloss1);
  172. printf("You have %d cash left\n",cashleft);
  173. }
  174.  
  175. if(betno2==s)
  176. {( cashwon2 = cash2 * 35 );
  177. printf("The bet number 2 has won %d \n", cashwon2);
  178. gainloss2=(cashwon2-cash2);
  179. printf("The profit gained back is %d\n", gainloss2);
  180. }
  181.  
  182. else
  183. {printf("Sorry, the bet number 2 has lost.\n");
  184. cashwon2= 0;
  185. (gainloss2=-1 * cash2);
  186. printf("You lost %d\n", gainloss2);
  187. (cashleft= cash2+ gainloss2);
  188. printf("You have %d cash left\n",cashleft);
  189. }
  190.  
  191. if(betno3==s)
  192. {( cashwon3 = cash3 *35 );
  193. printf("The bet number 3 has won %d \n", cashwon3);
  194. gainloss3=(cashwon3-cash3);
  195. printf("The profit gained back is %d\n", gainloss3);
  196. }
  197.  
  198. else
  199. {printf("Sorry, the bet number 3 has lost.\n");
  200. cashwon3= 0;
  201. (gainloss3=-1 * cash3);
  202. printf("You lost %d\n", gainloss3);
  203. (cashleft= cash3+ gainloss3);
  204. printf("You have %d cash left\n",cashleft);
  205. }
  206.  
  207.  
  208. if(betno4==s)
  209. {( cashwon4 = cash4 * 35 );
  210. printf("The bet number 4 has won %d \n", cashwon4);
  211. gainloss4=(cashwon4-cash4);
  212. printf("The profit gained back is %d\n", gainloss4);
  213. }
  214.  
  215. else
  216. {printf("Sorry, the bet number 4 has lost.\n");
  217. cashwon4= 0;
  218. (gainloss4=-1 * cash4);
  219. printf("You lost %d\n", gainloss4);
  220. (cashleft= cash4+ gainloss4);
  221. printf("You have %d cash left\n",cashleft);
  222. }
  223. //Displaying final value
  224. (totalcashwon = cashwon1 + cashwon2 +cashwon3 + cashwon4);
  225. printf("The total cashwon from your play is %d\n", totalcashwon);
  226. printf(" Thank you for playing\n");
  227.  
  228.  
  229. }