<mosaic.cnfolio.com>
PROGRAM
  1. // Declare an integer variable called bet intialize
  2. // Declare an integer variable called Mpot intialize
  3. // Declare an integer variable called limit and set to 100
  4. // Declare an integer variable called number intialize
  5. // Declare an integer variable called i intialize
  6. // Declare an integer variable called n and set to 4
  7. // Declare an integer variable called profit and intialize
  8.  
  9. // print "Welcome to my Roulette program."
  10.  
  11. // do
  12. // print "Enter a number from 1 to 36 you would like to bet on 4 times."
  13. // scan for value for variable bet
  14. // if bet is less than 1 or more than 36
  15. // print " Number should be from 1 to 36"
  16. // while bet is less than 1 or more than 36
  17.  
  18. // do
  19. // print "Place your bet amount"
  20. // scan for value for variable Mpot
  21. // if variable Mpot is greater than variable limit
  22. // print "Your limit is " variable limits value "please bet within the limit"
  23. // while variable Mpot is greater than limit
  24.  
  25. // print "You have bet " variable Mpot's value "on the number" variable bet's value
  26.  
  27. // srand
  28.  
  29. //for loopcounter variable = 0 loops while variable for loopcounter is less than zero and variable Mpot is less than variable limit
  30. // variable number equals rand
  31.  
  32.  
  33. #include <stdio.h>
  34. #include <stdlib.h>
  35. #include <time.h>
  36.  
  37. int main(void)
  38. {
  39.  
  40. int bet =0;
  41. int Mpot = 0;
  42. int limit = 100;
  43. int number = 0;
  44. int i = 0;
  45. int n = 4;
  46. int profit = 0; //Variables declared and initialzed
  47.  
  48.    
  49. printf("Welcome to my Roulette program.");
  50.    
  51. do
  52. {
  53. printf("\n Enter a number from 1 to 36 you would like to bet on 4 times.");
  54. scanf("%d", &bet);
  55. if (bet<1 || bet>36)
  56. {
  57. printf(" Number should be from 1 to 36");
  58. }
  59. }
  60. while (bet<1 || bet>36);       // Do while loop checks if a number between 1 - 36 has been entered and assigns it to bet
  61.  
  62. do
  63. {
  64. printf("\n Place your bet amount");
  65. scanf("%d", &Mpot);
  66. if (Mpot > limit)
  67. {
  68. printf("Your limit is %d please bet within the limit", limit);
  69. }
  70. }
  71. while (Mpot > limit);            // Do while loop checks if a bet between 0 and 100 has been entered and assigns it to bet
  72.  
  73. printf("\n  You have bet %d on the number %d\n", Mpot, bet);   // Prints the number chosen and amount bet on it
  74.  
  75. srand((unsigned)time(NULL)); //seeds the random number generator with the current system time
  76.  
  77. for (i = 0 ; i < n && Mpot < limit; i++);
  78. {
  79. number = rand() % 36 + 1;
  80. printf("\nThe ball landed on %d\n", number)// for loop that repeats the bet 4 times and gets the random numbers
  81.  
  82. if (number == bet)
  83. {
  84. limit+= (Mpot * 35);
  85. printf("You Won! You now have %d.\n", limit);
  86. }
  87. else
  88. {
  89. limit -= Mpot;
  90. printf("You lost %d. You now have %d.\n", Mpot, limit);
  91. }                  // if else statement that says if you have won or lost the bet and how much you have won or lost from that bet
  92.  
  93. }
  94. if (limit > 100)
  95. {
  96. profit = limit - 100;
  97. printf("Profit = %d", profit);
  98. }
  99. else
  100. {
  101. profit = 100 - limit;
  102. printf("Loss = %d", profit);          // if else stament that says how much was made overall and how much was lost overall
  103. }
  104.  
  105. return 0;
  106. }