<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3.   READ users bet inputs
  4.   IF user does not enter 8 integer values for their bets
  5.     WRITE "ERROR: Please enter in eight integer values for your bets"
  6.   END IF
  7.       bet number 1 is less than 0 or greater than 37
  8.         WRITE "ERROR: Please enter a value between 0 and 37 (37 = 00) for your first bet number."
  9.           IF
  10.           bet number 2 is less than 0 or greater than 37
  11.             WRITE "ERROR: Please enter a value between 0 and 37 (37 = 00) for your second bet number."
  12.               IF
  13.                 bet number 3 is less than 0 or greater than 37
  14.                   WRITE "ERROR: Please enter a value between 0 and 37 (37 = 00) for your third bet number."
  15.                     IF
  16.                       bet number 4 is less than 0 or greater than 37
  17.                         WRITE "ERROR: Please enter a value between 0 and 37 (37 = 00) for your fourth bet number."
  18.                     END IF
  19.               END IF
  20.           END IF
  21.       END IF
  22.             bet amount 1 is less than or equal to 0
  23.               WRITE "Please enter a valid bet amount for your first bet."
  24.                 IF
  25.                   bet amount 2 is less than or equal to0
  26.                     WRITE "Please enter a valid bet amount for your second bet."
  27.                       IF
  28.                         bet amount 3 is less than or equal to 0
  29.                           WRITE "Please enter a valid bet amount for your third bet."
  30.                             IF
  31.                               bet amount 4 is less than or equal to 0
  32.                                 WRITE "Please enter a valid bet amount for your fourth bet."
  33.                             END IF
  34.                       END IF
  35.                 END IF
  36.           END IF
  37.                 bet amount 1 is equal to betamount 2
  38.                   WRITE "ERROR: Bet numbers one and two are the same. Please change one of them."
  39.                     IF
  40.                       bet amount 1 is equal to betamount 3
  41.                         WRITE "ERROR: Bet numbers one and three are the same. Please change one of them."
  42.                           IF
  43.                             bet amount 1 is equal to betamount 4
  44.                             WRITE "ERROR: Bet numbers one and four are the same. Please change one of them."
  45.                               IF
  46.                                 bet amount 2 is equal to betamount 3
  47.                                   WRITE "ERROR: Bet numbers two and three are the same. Please change one of them."
  48.                                     IF
  49.                                       bet amount 2 is equal to betamount 4
  50.                                         WRITE "ERROR: Bet numbers two and four are the same. Please change one of them."
  51.                                           IF
  52.                                             bet amount 3 is equal to betamount 4
  53.                                               WRITE "ERROR: Bet numbers three and four are the same. Please change one of them."
  54.                                           END IF
  55.                                     END IF
  56.                               END IF
  57.                           END IF
  58.                     END
  59.   IF bet number 1 is equal to the random roulette number
  60.     WRITE "The winning number is number"
  61.     WRITE "Bet number 1 is: betnumber1"
  62.     WRITE "Bet amount 1 is: betamount1"
  63.     WRITE "You have won a total of betamount1 * 35"
  64.   ELSE
  65.     WRITE "The winning number is number"
  66.     WRITE "Bet number 1 is: betnumber1"
  67.     WRITE "Bet amount 1 is: betamount1"
  68.     WRITE "You have lost a total of betamount1"
  69.   END IF
  70.         bet number 2 is equal to the random roulette number
  71.           WRITE "The winning number is number"
  72.           WRITE "Bet number 2 is: betnumber2"
  73.           WRITE "Bet amount 2 is: betamount2"
  74.           WRITE "You have won a total of betamount2 * 35"
  75.       ELSE
  76.         WRITE "The winning number is number"
  77.         WRITE "Bet number 2 is: betnumber2"
  78.         WRITE "Bet amount 2 is: betamount2"
  79.         WRITE "You have lost a total of betamount2"
  80.       END IF
  81.             bet number 3 is equal to the random roulette number
  82.               WRITE "The winning number is number"
  83.               WRITE "Bet number 3 is: betnumber3"
  84.               WRITE "Bet amount 3 is: betamount3"
  85.               WRITE "You have won a total of betamount3 * 35"
  86.           ELSE
  87.             WRITE "The winning number is number"
  88.             WRITE "Bet number 3 is: betnumber3"
  89.             WRITE "Bet amount 3 is: betamount3"
  90.             WRITE "You have lost a total of betamount3"
  91.           END IF
  92.                 bet number 4 is equal to the random roulette number
  93.                   WRITE "The winning number is number"
  94.                   WRITE "Bet number 4 is: betnumber4"
  95.                   WRITE "Bet amount 4 is: betamount4"
  96.                   WRITE "You have won a total of betamount4 * 35"
  97.               ELSE
  98.                 WRITE "The winning number is number"
  99.                 WRITE "Bet number 4 is: betnumber4"
  100.                 WRITE "Bet amount 4 is: betamount4"
  101.                 WRITE "You have lost a total of betamount4"
  102.               END 
  103.   WRITE final totals after all bets                         
  104. END
  105. */
  106.  
  107. #include <stdio.h>
  108. #include <stdlib.h>
  109. #include <time.h>
  110.  
  111. int main (void)
  112.  
  113. {
  114. int number;
  115. int betnumber1;
  116. int betnumber2;
  117. int betnumber3;
  118. int betnumber4;
  119. int betamount1;
  120. int betamount2;
  121. int betamount3;
  122. int betamount4;
  123. int balance1;
  124. int balance2;
  125. int balance3;
  126. int balance4;
  127.  
  128. srand(time(0));
  129. number = rand() % 38;
  130.  
  131. /* scanning the inputs for the bets as well as making sure they are eight integer values */
  132. if (scanf("%d %d %d %d %d %d %d %d", &betnumber1, &betamount1, &betnumber2, &betamount2, &betnumber3, &betamount3, &betnumber4, &betamount4) != 8)
  133. {
  134. printf("ERROR: Please enter in eight integer values for your bets");
  135. exit(0);
  136. }
  137.  
  138. /* displays error messages depending to make sure the values entered by the user are correct */
  139.  
  140. if (betnumber1 < 0 || betnumber1 > 37 ){
  141. printf("ERROR: Please enter a value between 0 and 37 (37 = 00) for your first bet number.");
  142. exit(0);
  143. }
  144.  
  145. if (betnumber2 < 0 || betnumber2 > 37 ){
  146. printf("ERROR: Please enter a value between 0 and 37 (37 = 00) for your second bet number.");
  147. exit(0);
  148. }
  149.  
  150. if (betnumber3 < 0 || betnumber3 > 37 ){
  151. printf("ERROR: Please enter a value between 0 and 37 (37 = 00) for your third bet number.");
  152. exit(0);
  153. }
  154.  
  155. if (betnumber4 < 0 || betnumber4 > 37 ){
  156. printf("ERROR: Please enter a value between 0 and 37 (37 = 00) for your fourth bet number.");
  157. exit(0);
  158. }
  159.  
  160. if (betamount1 <= 0){
  161. printf("ERROR: Please enter a valid bet amount for your first bet.");
  162. exit(0);
  163. }
  164.  
  165. if (betamount2 <= 0){
  166. printf("ERROR: Please enter a valid bet amount for your second bet.");
  167. exit(0);
  168. }
  169.  
  170. if (betamount3 <= 0){
  171. printf("ERROR: Please enter a valid bet amount for your third bet.");
  172. exit(0);
  173. }
  174.  
  175. if (betamount4 <= 0){
  176. printf("ERROR: Please enter a valid bet amount for your fourth bet.");
  177. exit(0);
  178. }
  179.  
  180. if (betnumber1 == betnumber2){
  181. printf("ERROR: Bet numbers one and two are the same. Please change one of them.");
  182. exit(0);
  183. }
  184.  
  185. if (betnumber1 == betnumber3){
  186. printf("ERROR: Bet numbers one and three are the same. Please change one of them.");
  187. exit(0);
  188. }
  189.  
  190. if (betnumber1 == betnumber4){
  191. printf("ERROR: Bet numbers one and four are the same. Please change one of them.");
  192. exit(0);
  193. }
  194.  
  195. if (betnumber2 == betnumber3){
  196. printf("ERROR: Bet numbers two and three are the same. Please change one of them.");
  197. exit(0);
  198. }
  199.  
  200. if (betnumber2 == betnumber4){
  201. printf("ERROR: Bet numbers two and four are the same. Please change one of them.");
  202. exit(0);
  203. }
  204.  
  205. if (betnumber3 == betnumber4){
  206. printf("ERROR: Bet numbers three and four are the same. Please change one of them.");
  207. exit(0);
  208. }
  209.  
  210. printf("-------------------------------------------------\n");
  211.  
  212. if (betnumber1 == number){
  213. printf("The Winning Number is %d \n", number);
  214. printf("Bet Number 1 is: %d \n", betnumber1);
  215. printf("Bet Amount 1 is: $%d.00 \n", betamount1);
  216. printf("You have won a total of $%d.00 from this bet\n", betamount1 + betamount1 * 35);
  217. balance1 = betamount1 + betamount1 * 35;
  218. }
  219. else
  220. {
  221. printf("The Winning Number is %d \n", number);
  222. printf("Bet Number is: %d \n", betnumber1);
  223. printf("Bet Amount is: $%d.00 \n", betamount1);
  224. printf("You lost a total of $%d.00 from this bet\n", betamount1);
  225. balance1 = 0 - betamount1;
  226. }
  227. if (betnumber2 == number){
  228. printf("\nBet Number 2 is: %d \n", betnumber2);
  229. printf("Bet Amount 2 is: $%d.00 \n", betamount2);
  230. printf("You have won a total of $%d.00 from this bet\n", betamount2 + betamount2 * 35);
  231. balance2 = balance1 + betamount2 + betamount2 * 35;
  232. }
  233. else
  234. {
  235. printf("\nBet Number 2 is: %d \n", betnumber2);
  236. printf("Bet Amount 2 is: $%d.00 \n", betamount2);
  237. printf("You lost a total of $%d.00 from this bet\n", betamount2);
  238. balance2 = balance1 - betamount2;
  239. }
  240. if (betnumber3 == number){
  241. printf("\nBet Number 3 is: %d \n", betnumber3);
  242. printf("Bet Amount 3 is: $%d.00 \n", betamount3);
  243. printf("You have won a total of $%d.00 from this bet\n", betamount3 + betamount3 * 35);
  244. balance3 = balance2 + betamount3 + betamount3 * 35;
  245. }
  246. else
  247. {
  248. printf("\nBet Number 3 is: %d \n", betnumber3);
  249. printf("Bet Amount 3 is: $%d.00 \n", betamount3);
  250. printf("You lost a total of $%d.00 from this bet\n", betamount3);
  251. balance3 = balance2 - betamount3;
  252. }
  253. if (betnumber4 == number){
  254. printf("\nBet Number 4 is: %d \n", betnumber4);
  255. printf("Bet Amount 4 is: $%d.00 \n", betamount4);
  256. printf("You have won a total of $%d.00 from this bet\n", betamount4 + betamount4 * 35);
  257. balance4 = balance3 + betamount4 + betamount4 * 35;
  258. }
  259. else
  260. {
  261. printf("\nBet Number 4 is: %d \n", betnumber4);
  262. printf("Bet Amount 4 is: $%d.00 \n", betamount4);
  263. printf("You lost a total of $%d.00 from this bet\n", betamount4);
  264. balance4 = balance3 - betamount4;
  265. }
  266.  
  267. printf("\nYour updated balance is $%d.00\n", balance4);
  268.  
  269. printf("-------------------------------------------------\n");
  270. }