<mosaic.cnfolio.com>
PROGRAM
  1. /*START
  2.   call title function
  3.   define integer values
  4.   ask player to place bets
  5.   if no bets placed
  6.   display error message
  7.   if bet number is less than 0 and higher than 37
  8.   display error message
  9.   while there are bets
  10.   generate random numbers
  11.   if the winning bet is 37
  12.   display winning number as 00
  13.   else display normal winning numbers
  14.   while generate winning number
  15.   if winning number equals user value
  16.   then increase total winnings
  17.   else increase total loss
  18.   display total winning
  19.   display total loss
  20.   display total profit
  21. END*/
  22.  
  23.  
  24.  
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <time.h>     
  28.  
  29.  
  30.  
  31.  
  32. int main() 
  33. {
  34.  
  35. int bet_number[4];
  36. int bet_amount[4];
  37. int roulette[4];
  38. int winnings[4];
  39. int loss [4];
  40. int total_winnings = 0;
  41. int total_loss = 0;
  42.  
  43. print_title();
  44.  
  45. printf("Place your bets:\n");
  46.  
  47. for (int i = 0;  i<4 ; i++) {            //loop 4 times. get 2 user values each time as bet number and bet amount
  48.  
  49. scanf("%d %d", &bet_number[i], &bet_amount[i]);
  50. if (bet_number[i] < 0 || bet_amount[i] < 0) {       //if the user value is 0 or bet value is 0, then  display error message
  51. printf ("You have not placed any bets\n");
  52.  
  53. }
  54. if (bet_number[i] > 37 || bet_amount[i] < 0){       //if user value is more than 37 , display error message
  55. printf ("You can place bets on number between 0 - 37, where 37 is 00\n");
  56. exit(0);           //exits the program if statement is true
  57. }
  58.  
  59. else {
  60. printf("Your bet number %d consists of: number %d for %d\n", i+1, bet_number[i], bet_amount[i]);
  61.  
  62. }
  63. }
  64. printf("\n");
  65.  
  66. srand(time(NULL));           //generate random value
  67. for (int i = 0; i<4; i++) {
  68. roulette[i] = (rand() % 38);   //generate random number between 0 - 37
  69. if (roulette[i] == 37) {       // when roulette value is 37, displays message as 00
  70. printf("Round %d: The ball has landed on 00\n", i+1);
  71. }
  72. else{
  73. printf("Round %d: The ball has landed on: %d\n", i+1, roulette[i]);
  74.  }
  75. }
  76.  
  77. printf("\n");
  78.  
  79.  
  80. for (int i = 0; i<4; i++) {
  81. if (bet_number[i] == roulette[i]) {     //if roulette value is equal to users number value, then increase total winnings and display message
  82. winnings[i] = bet_amount[i] + bet_amount[i] *35;
  83. total_winnings = total_winnings + winnings[i];
  84. printf("Round %d: You won $%d\n",i+1, winnings[i]);
  85. }
  86.  
  87. else{                               //if roulette value is not equal to users number value, then increase total loss and display message
  88. winnings[i] = 0;                   
  89. loss[i] = bet_amount[i];
  90. total_loss = total_loss + loss[i];
  91. printf("Round %d: You lost %d\n",i+1, loss[i]);
  92. }
  93.  
  94. }
  95. printf("You lost a total of %d\n", total_loss);
  96. printf("You won a total of %d\n", total_winnings);
  97.  
  98. printf ("Your end profit is %d", total_winnings - total_loss);   //display total profit
  99. }
  100.  
  101. void print_title(void)
  102. {
  103.     printf("       \n");
  104.     printf("*******  ******   *      *  *      ****** ******* *******  ******        \n");
  105.     printf("*     * *      *  *      *  *      *         *       *     *        \n");
  106.     printf("******* *      *  *      *  *      *         *       *     *        \n");
  107.     printf("*   *   *      *  *      *  *      ****      *       *     ****        \n");
  108.     printf("*    *  *      *  *      *  *      *         *       *     *        \n");
  109.     printf("*     *  ******    ******   ****** ******    *       *     ******        ");
  110.     printf("                           \n");
  111. }