<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3. Scan inputs
  4. Check each input is viable for the program to function
  5. If not suitable display appropriate error message
  6. Log 1st bet number appropriateley (required due to double zero)
  7. Generate a random number corresponding to 00 or 0-36
  8. If the bet number matches the random number calculate payout and display the profit on the bet
  9. If the numbers don't match display the loss on the bet
  10. Repeat for remaining 3 bets
  11. Calculate and display end total
  12. END
  13. */
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <time.h>
  17. int main(void)
  18. {
  19. srand (time(0));
  20. char betnumber1[3], betnumber2[3], betnumber3[3], betnumber4[3];
  21. int number1, number2, number3, number4, random1, random2, random3, random4;
  22. double betvalue1, betvalue2, betvalue3, betvalue4, payout1, payout2, payout3, payout4, loss1, loss2, loss3, loss4, total;
  23. scanf("%s %s %s %s %lf %lf %lf %lf", &betnumber1, &betnumber2, &betnumber3, &betnumber4, &betvalue1, &betvalue2, &betvalue3, &betvalue4);
  24. if (0<=betnumber1<=36)
  25. {
  26. if (0<=betnumber2<=36)
  27. {
  28. if (0<=betnumber3<=36)
  29. {
  30. if (0<=betnumber4<=36)
  31. {
  32. if (betvalue1>0)
  33. {
  34. if (betvalue2>0)
  35. {
  36. if (betvalue3>0)
  37. {
  38. if (betvalue4>0)
  39. {
  40. if (betnumber1[0] == '0' && betnumber1[1] == '0')
  41. {
  42.  number1 = 37;
  43. }
  44. else {
  45.        number1 = atoi(betnumber1);
  46. }
  47. random1 = rand()%38;
  48.   if (random1 == betnumber1)
  49. {
  50.  payout1=betvalue1*35 + betvalue1;
  51.  printf("1st Bet Number = %s\n 1st Bet Amount = %.2lf\n 1st Winning Number = %d\n 1st Bet Payout = %.2lf\n 1st Bet Profit = %.2lf\n" , betnumber1, betvalue1, random1, payout1, payout1);
  52. }
  53. else
  54. {
  55.  loss1=betvalue1;
  56.  printf("1st Bet Number = %s\n 1st Bet Amount = %.2lf\n 1st Winning Number = %d\n 1st Bet Payout = 0\n 1st Bet Loss = %.2lf\n" , betnumber1, betvalue1, random1, loss1);
  57. }
  58. if (betnumber2[0] == '0' && betnumber2[1] == '0')
  59. {
  60.  number2 = 37;
  61. }
  62. else {
  63.        number2 = atoi(betnumber2);
  64. }
  65. random2 = rand()%38;
  66.   if (random2 == betnumber2)
  67. {
  68.  payout2=betvalue2*35 + betvalue2;
  69.  printf("2nd Bet Number = %s\n 2nd Bet Amount = %.2lf\n 2nd Winning Number = %d\n 2nd Bet Payout = %.2lf\n 2nd Bet Profit = %.2lf\n" , betnumber2, betvalue2, random2, payout2, payout2);
  70. }
  71. else
  72. {
  73.  loss2=betvalue2;
  74.  printf("2nd Bet Number = %s\n 2nd Bet Amount = %.2lf\n 2nd Winning Number = %d\n 2nd Bet Payout = 0\n 2nd Bet Loss = %.2lf\n" , betnumber2, betvalue2, random2, loss2);
  75. }
  76. if (betnumber3[0] == '0' && betnumber3[1] == '0')
  77. {
  78.  number3 = 37;
  79. }
  80. else {
  81.        number3 = atoi(betnumber3);
  82. }
  83. random3 = rand()%38;
  84.   if (random3 == betnumber3)
  85. {
  86.  payout3=betvalue3*35 + betvalue3;
  87.  printf("3rd Bet Number = %s\n 3rd Bet Amount = %.2lf\n 3rd Winning Number = %d\n 3rd Bet Payout = %.2lf\n 3rd Bet Profit = %.2lf\n" , betnumber3, betvalue3, random3, payout3, payout3);
  88. }
  89. else
  90. {
  91.  loss3=betvalue3;
  92.  printf("3rd Bet Number = %s\n 3rd Bet Amount = %.2lf\n 3rd Winning Number = %d\n 3rd Bet Payout = 0\n 3rd Bet Loss = %.2lf\n" , betnumber3, betvalue3, random3, loss3);
  93. }
  94. if (betnumber4[0] == '0' && betnumber4[1] == '0')
  95. {
  96.  number4 = 37;
  97. }
  98. else {
  99.        number4 = atoi(betnumber4);
  100. }
  101. random4 = rand()%38;
  102.   if (random4 == betnumber4)
  103. {
  104.  payout4=betvalue4*35 + betvalue4;
  105.  printf("4th Bet Number = %s, 4th Bet Amount = %.2lf, 4th Winning Number = %d, 4th Bet Payout = %.2lf, 4th Bet Profit = %.2lf" , betnumber4, betvalue4, random4, payout4, payout4);
  106. }
  107. else
  108. {
  109.  loss4=betvalue4;
  110.  printf("4th Bet Number = %s, 4th Bet Amount = %.2lf, 4th Winning Number = %d, 4th Bet Payout = 0, 4th Bet Loss = %.2lf" , betnumber4, betvalue4, random4, loss4);
  111.  total=payout1+payout2+payout3+payout4-loss1-loss2-loss3-loss4;
  112.  printf("End Total = %.2lf", total);
  113. }
  114. }
  115. else
  116. {
  117. printf( "Please insert a 4th bet amount greater than 0");
  118. }
  119. }
  120. else
  121. {
  122. printf( "Please insert a 3rd bet amount greater than 0");
  123. }
  124. }
  125. else
  126. {
  127. printf( "Please insert a 2nd bet amount greater than 0");
  128. }
  129. }
  130. else
  131. {
  132. printf( "Please insert a 1st bet amount greater than 0");
  133. }
  134. }
  135. else
  136. {
  137. printf( "Please insert a 4th bet number of 00 or 0-36");
  138. }
  139. }
  140. else
  141. {
  142. printf( "Please insert a 3rd bet number of 00 or 0-36");
  143. }
  144. }
  145. else
  146. {
  147. printf( "Please insert a 2nd bet number of 00 or 0-36");
  148. }
  149. }
  150. else
  151. {
  152. printf( "Please insert a 1st bet number of 00 or 0-36");
  153. }
  154. }