<mosaic.cnfolio.com>
PROGRAM
1. /*
2. START
3. Obtain 8 inputs
4. make 4 pairs(1st bet number and 2nd bet amount)
5. genarate random number between 0 to 36 inlcuding 00
6. Display random number(winning number)
7. IF any input values(1st bet number) are more than 35 or negative
8.    THEN
9.    Display error message
10.    IF any input values(2nd bet amount) are negative value
11.    THEN
12.    Display error message
13.    IF any input values are missing
14.    THEN
15.    Display error message
16.    IF
17. IF bet number = random number
18.    THEN
19.    Display that you won
20.    Multiply winning bet amount by 36 and add it to total
21.    Display bet amounts from winning and non winning bets
22.    Subtract bet amounts(non winning bets) from total
23.    Display total profit
24. ELSE
25.    Display that you didnt win
26.    Subtratct all the bet amounts and display total loss
27. END IF
28. END
29. */
30.
31. #include<stdio.h>
32. #include<stdlib.h>
33.
34. int main()
35. {
36.
37. int betnum;          /*declares the bet number*/
38. float betamount;    /*declares bet amount*/
39. int roulette;
40. float loss;
41. float profit;
42. float totalloss=0;
43. float totalprofit=0;
44. float total=0;
45.
46. printf("LETS PLAY ROULETTE!\n\n");
47.
48.
49. for (int i=0; i<4 ; i++)   /*executes loop till "i" is less than 4*/
50. {
51. scanf("%d %f", &betnum[i], &betamount[i]);   /*scans the values*/
52. if (betnum[i]>36 || betnum[i]<0 || betamount[i]<=0) /*declares a control statement*/
53. {
54. printf("Your input is invalid\n")/*executes if the statement is true*/
55. exit(0); /*Doesn't further read any insturctions*/
56. }
57. else /*executes if the above if statement isnt true*/
58. {
59. printf("Your bet number %d is roulette number [%02d] for \$%.2f.\n", i+1, betnum[i], betamount[i])/*Displays your input number and amount*/
60. }
61. }
62. printf("Lets see if you are lucky...\n");
63. printf("***************************\n***************************\n");
64.
65. srand(time(NULL));
66. for (int i=0; i<4; i++)
67. {
68. roulette[i] = (rand()%38); /*random integer between 0-37*/
69. if (roulette[i] == 37)
70. {
71. roulette[i]=00; /*sotres as 00 if random number is 37*/
72. printf("For Round %d : The ball landed on %02d!\n", i+1, roulette[i]);
73. }
74. else
75. {
76. printf("For Round %d : The ball landed on %d!\n", i+1, roulette[i])/*Displays the random integer where ball landed*/
77. }
78. }
79. printf("===========================\n");
80.
81.
82. for (int i = 0; i<4; i++)
83. {
84. if (betnum[i] == roulette[i]) {
85. profit[i] = betamount[i] + betamount[i] *35; /*bet amount times 35 and add original bet amount */
86. totalprofit = totalprofit + profit[i];
87. printf("For Round %d: You won \$%.2f\n",i+1, profit[i]); /*Displays profit for the round if statement is true*/
88. }
89.
90. else{
91. profit[i] = 0;
92. loss[i] = betamount[i];
93. totalloss = totalloss + loss[i];
94. printf("For Round %d: You lost \$%.2f\n",i+1, loss[i]); /*Displays loss for the round if the statement is false*/
95. }
96. }
97. printf("You lost \$%.2f\n", totalloss);
98. printf("You won \$%.2f\n", totalprofit);
99.
100. printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
101. total = totalprofit - totalloss; /*Grand total*/
102. if (total<0)
103. {
104. printf ("Therefore, Your total loss is \$%.2f", total); /*Displays loss summing everything if the statement is true*/
105. }
106. else
107. {
108. printf("Your total profit is \$%.2f", total); /*Displays profit if statement is false*/
109. }
110. }