<mosaic.cnfolio.com>
PROGRAM
  1. /*START
  2.    ASSIGN all data identifiers their location in memory
  3.    SET minimum and maximum values for bet and number
  4.    INITIALIZE the american style roulette wheel array
  5.    CHECK for inputs and save them to their data identifiers
  6.    
  7.    DISPLAY the round number
  8.    IF the bet and the number are within their given perameters
  9.       THEN     
  10.             GENERATE random number 1 to 37
  11.             SET number1 as the randomly generated number
  12.            
  13.             DISPLAY the number the player has picked
  14.             DISPLAY the bet the player has placed
  15.            
  16.             IF the number the player has picked is equal to the winning roulette number
  17.                THEN
  18.                      DISPLAY earnings and total winnings
  19.                      SET sum1 as total winnings
  20.             ELSE
  21.                DISPLAY total losses
  22.                SET sum1 as total losses
  23.             END IF
  24.    ELSE
  25.       DISPLAY error message
  26.       DISPLAY parameters for number and bet
  27.       SET sum1 to 0
  28.    END IF
  29.    
  30.    DISPLAY the round number
  31.    IF the bet and the number are within their given perameters
  32.       THEN     
  33.             GENERATE random number 1 to 37
  34.             SET number2 as the randomly generated number
  35.            
  36.             DISPLAY the number the player has picked
  37.             DISPLAY the bet the player has placed
  38.            
  39.             IF the number the player has picked is equal to the winning roulette number
  40.                THEN
  41.                      DISPLAY earnings and total winnings
  42.                      SET sum2 as total winnings
  43.             ELSE
  44.                DISPLAY total losses
  45.                SET sum2 as total losses
  46.             END IF
  47.    ELSE
  48.       DISPLAY error message
  49.       DISPLAY parameters for number and bet
  50.       SET sum2 to 0
  51.    END IF
  52.    
  53.    DISPLAY the round number
  54.    IF the bet and the number are within their given perameters
  55.       THEN     
  56.             GENERATE random number 1 to 37
  57.             SET number3 as the randomly generated number
  58.            
  59.             DISPLAY the number the player has picked
  60.             DISPLAY the bet the player has placed
  61.            
  62.             IF the number the player has picked is equal to the winning roulette number
  63.                THEN
  64.                      DISPLAY earnings and total winnings
  65.                      SET sum3 as total winnings
  66.             ELSE
  67.                DISPLAY total losses
  68.                SET sum3 as total losses
  69.             END IF
  70.    ELSE
  71.       DISPLAY error message
  72.       DISPLAY parameters for number and bet
  73.       SET sum3 to 0
  74.    END IF
  75.  
  76.    DISPLAY the round number
  77.    IF the bet and the number are within their given perameters
  78.       THEN     
  79.             GENERATE random number 1 to 37
  80.             SET number4 as the randomly generated number
  81.            
  82.             DISPLAY the number the player has picked
  83.             DISPLAY the bet the player has placed
  84.            
  85.             IF the number the player has picked is equal to the winning roulette number
  86.                THEN
  87.                      DISPLAY earnings and total winnings
  88.                      SET sum4 as total winnings
  89.             ELSE
  90.                DISPLAY total losses
  91.                SET sum4 as total losses
  92.             END IF
  93.    ELSE
  94.       DISPLAY error message
  95.       DISPLAY parameters for number and bet
  96.       SET sum4 to 0
  97.    END IF
  98.    
  99.    DISPLAY end of game message
  100.    DISPLAY net profit
  101. END*/
  102.  
  103. #include<stdio.h>
  104. #include <stdlib.h>
  105. #include <time.h>
  106. #include <string.h>
  107.  
  108. int main(void)
  109. {
  110.  
  111. /*Assign data identifires*/
  112. int num1, bet1, num2, bet2, num3, bet3, num4, bet4;
  113. int number1, number2, number3, number4;
  114. int sum1, sum2, sum3, sum4;
  115.  
  116. /*Set minimun and maximum values for bets and numbers*/
  117. int minnum = 0;
  118. int maxnum = 36;
  119. int minbet = 1;
  120. int maxbet = 1000;
  121.  
  122. /*Set array for roulette wheel*/
  123. int slot[] = {0, 28, 9, 26, 30, 11, 7, 20, 32, 17, 5, 22, 34, 15, 3, 24, 36, 13, 1, 00, 27, 10, 25, 29, 12, 819, 31, 18, 6, 21, 33, 16, 4, 23, 35, 14, 2};
  124.  
  125. /*Check for inputs*/
  126. scanf("%d %d %d %d %d %d %d %d", &num1, &bet1, &num2, &bet2, &num3, &bet3, &num4, &bet4);
  127.  
  128. /*Round 1*/
  129. printf(" ROUND 1: \n");
  130.  
  131. /*Check that the minimun and maximum requirments for bet1 and num1 have been met*/
  132. if (((num1 >= minnum)&&(num1 <= maxnum))&&((bet1 >= minbet)&&(bet1 <= maxbet)))
  133.  
  134.    /*Generate random number for bet1 from 0 to 37*/
  135.    {srand(time(0));
  136.    do
  137.    {number1 = rand();}
  138.    while (number1 >= 37);
  139.  
  140.    /*Display the bet placed, the number picked, the winning number, and any winnings or losses made*/
  141.    printf("You bet %d on roulette number %d \n", bet1, num1);
  142.    printf("Winning roulette number is %d \n", slot[number1]);
  143.  
  144.    if (num1 == slot[number1])
  145.       {printf("You won this round! Your earnings are %d and your total profit is %d \n", (37*bet1), ((37*bet1)+bet1));
  146.       sum1 = ((37*bet1)+bet1);}
  147.    else {printf("Unfortunatly you lost this round. Your total loss is %d \n", bet1);
  148.       sum1 = (-bet1);}}
  149.        
  150.  
  151. /*Print error message as the inputs for bet1 are not valid*/
  152. else {printf("Either you number or bet isn't valid.\n The numbers range between 0 and 36, and the bet can be between $1 and $1000.\n Please try again. \n");
  153.      sum1 = 0;}
  154.      
  155. /*Round 2*/
  156. printf("\n ROUND 2: \n");
  157.  
  158. /*Check that the minimun and maximum requirments for bet2 and num2 have been met*/
  159. if (((num2 >= minnum)&&(num2 <= maxnum))&&((bet2 >= minbet)&&(bet2 <= maxbet)))
  160.  
  161.    /*Generate random number for bet2 from 0 to 37*/
  162.    {srand(time(0));
  163.    do
  164.    {number2 = rand();}
  165.    while (number2 >= 37);
  166.    
  167.    /*Display the bet placed, the number picked, the winning number, and any winnings or losses made*/
  168.    printf("You bet %d on roulette number %d \n", bet2, num2);
  169.    printf("Winning roulette number is %d \n", slot[number2]);
  170.    
  171.    if (num2 == slot[number2])
  172.       {printf("You won this round! Your earnings are %d and your total profit is %d \n", (37*bet2), ((37*bet2)+bet2));
  173.       sum2 = ((37*bet2)+bet2);}
  174.    else {printf("Unfortunatly you lost this round. Your total loss is %d \n", bet2);
  175.         sum2 = (-bet2);}}
  176.  
  177. /*Print error message as the inputs for bet2 are not valid*/
  178. else {printf("Either you number or bet isn't valid.\n The numbers range between 0 and 36, and the bet can be between $1 and $1000.\n Please try again. \n");
  179.      sum2 = 0;}
  180.  
  181. /*Round 3*/
  182. printf("\n ROUND 3: \n");
  183.  
  184. /*Check that the minimun and maximum requirments for bet2 and num2 have been met*/
  185. if (((num3 >= minnum)&&(num3 <= maxnum))&&((bet3 >= minbet)&&(bet3 <= maxbet)))
  186.  
  187.    /*Generate random number for bet3 from 0 to 37*/
  188.    {srand(time(0));
  189.    do
  190.    {number3 = rand();}
  191.    while (number3 >= 37);
  192.    
  193.    /*Display the bet placed, the number picked, the winning number, and any winnings or losses made*/
  194.    printf("You bet %d on roulette number %d \n", bet3, num3);
  195.    printf("Winning roulette number is %d \n", slot[number3]);
  196.    
  197.    if (num3 == slot[number3])
  198.       {printf("You won this round! Your earnings are %d and your total profit is %d \n", (37*bet3), ((37*bet3)+bet3));
  199.       sum3 = ((37*bet3)+bet3);}
  200.    else {printf("Unfortunatly you lost this round. Your total loss is %d \n", bet3);
  201.         sum3 = (-bet3);}}
  202.  
  203. /*Print error message as the inputs for bet3 are not valid*/
  204. else {printf("Either you number or bet isn't valid.\n The numbers range between 0 and 36, and the bet can be between $1 and $1000.\n Please try again. \n");
  205.      sum3 = 0;}
  206.      
  207. /*Round 4*/
  208. printf("\n ROUND 4: \n");
  209.  
  210. /*Check that the minimun and maximum requirments for bet4 and num4 have been met*/
  211. if (((num4 >= minnum)&&(num4 <= maxnum))&&((bet4 >= minbet)&&(bet4 <= maxbet)))
  212.  
  213.    /*Generate random number for bet4 from 0 to 37*/
  214.    {srand(time(0));
  215.    do
  216.    {number4 = rand();}
  217.    while (number4 >= 37);
  218.    
  219.    /*Display the bet placed, the number picked, the winning number, and any winnings or losses made*/
  220.    printf("You bet %d on roulette number %d \n", bet4, num4);
  221.    printf("Winning roulette number is %d \n", slot[number4]);
  222.    
  223.    if (num4 == slot[number4])
  224.       {printf("You won this round! Your earnings are %d and your total profit is %d \n", (37*bet4), ((37*bet4)+bet4));
  225.       sum4 = ((37*bet4)+bet4);}
  226.    else {printf("Unfortunatly you lost this round. Your total loss is %d \n", bet4);
  227.         sum4 = (-bet4);}}
  228.  
  229. /*Print error message as the inputs for bet4 are not valid*/
  230. else {printf("Either you number or bet isn't valid.\n The numbers range between 0 and 36, and the bet can be between $1 and $1000.\n Please try again. \n");
  231.      sum4 = 0;}
  232.  
  233. /*Add up all winnings and losses and display the total*/
  234. printf("\nYou four bets are over.\nThe total amount of money you have is %d", (sum1+sum2+sum3+sum4));
  235.  
  236. }