Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. /*****************************************************************************************************
  2. * Program Name: Prog 06
  3. * Author: Patrick Barnett
  4. * Date: 12 / 11 / 19
  5. * Course/Section CSC - 110 - 302
  6. * Program Description:
  7. * Slot machine game. Asks user for how much money they would like to start with. Then will ask for
  8. * a wager amount. The slot machine will *spin* and give you a number (1-7). The goal is to get
  9. * at least two like numbers, triple sevens nets you triple your wager.
  10. *
  11. *****************************************************************************************************/
  12.  
  13. /**************************************** Compiler Directives ***************************************/
  14.  
  15. #include "pch.h"
  16. #include <string>
  17. #include <cstdlib>
  18. #include <iostream>
  19. #include <iomanip>
  20. #include <cmath>
  21.  
  22. using namespace std;
  23.  
  24. /************************************ Global Data Declarations **************************************/
  25.  
  26. // None in this program.
  27.  
  28. /************************************* Function Prototypes ******************************************/
  29.  
  30. //None in this program.
  31.  
  32. /*****************************************************************************************************
  33. Function Name: Main
  34. Author: Patrick Barnett
  35. Date: 12/11/2019
  36. Function Description:
  37. Asks user for how much money they will be betting with. Gets a wager amount, then spins. if
  38. numbers match double or triple the wager.
  39.  
  40. Pseudocode:
  41. Level 0
  42. -------
  43. Seed generator
  44. Ask user for bank
  45. Ask for wager amount
  46. Spin The Slots
  47. Check spin for like numbers
  48. Bank ran out
  49.  
  50. level 1
  51. -------
  52. Seed generator
  53. srand(static_cast<unsigned int>(time(0)))
  54. Ask user for bank
  55. output "How much money will you be playing with today?"
  56. input bank
  57. Ask for wager amount
  58. output "What is your wager on this spin?"
  59. if wager > bank then
  60. output "You don't have that much to wager."
  61. else
  62. input wager
  63. bank -= wager
  64. Spin The Slots
  65. for counter = 0 to SIZE-1 by +1
  66. spin[counter] = (rand() % (7 - 1 + 1)) + 1
  67. Check spin for like numbers
  68. else if spin[0] == spin[1] then
  69. bank += wager * 2
  70. else if spin[1] == spin[2] then
  71. bank += wager * 2
  72. else if spin[2] == spin[0] then
  73. bank += wager * 2
  74. check for lucky sevens
  75. for counter = 0 to SIZE-1 by +1
  76. luckyseven += spin[counter]
  77. if luckyseven == 21 then
  78. bank += wager * 3
  79. Bank ran out
  80. output "thanks for plying please come back again!"
  81.  
  82.  
  83. *******************************************************************************************************/
  84.  
  85. /********************************** Main Function ***************************************************/
  86.  
  87. int main()
  88. {
  89. //Local Constant
  90. const int SIZE = 3;
  91.  
  92. //local Variables
  93. int spin[SIZE];
  94. int bank;
  95. int wager;
  96. int counter;
  97. int luckyseven = 0;
  98. int spincount = 1;
  99.  
  100. /********************** Begin Main Function Executables ********************************/
  101.  
  102. //Seed the generator
  103. srand(static_cast<unsigned int>(time(0)));
  104.  
  105. //Ask for bank
  106. cout << "How much money would you like to gamble with today? ---> ";
  107. cin >> bank;
  108.  
  109. //Ask for wager
  110. while (bank > 0)
  111. {
  112. cout << "What would you like to wager on this spin? ";
  113. cin >> wager;
  114. if (wager > bank)
  115. cout << "You do not have that much to bet!" << endl;
  116. else if ((isdigit(wager)) == false)
  117. cout << "You entered in a letter instead of a number.";
  118. else
  119. {
  120. bank -= wager;
  121. //Spin the slots
  122. cout << "Time to spin the slots!! Spin Count: " << spincount << endl;
  123. spincount++;
  124. cout << "+-+-+-+" << endl;
  125. for (counter = 0; (counter <= (SIZE - 1)); counter++)
  126. {
  127. spin[counter] = (rand() % (7 - 1 + 1)) + 1;
  128. cout << "|" << spin[counter];
  129. }
  130. cout << "|" << endl << "+-+-+-+" << endl;
  131.  
  132. //Check for Lucky sevens
  133. for (counter = 0; (counter >= (SIZE - 1)); counter++)
  134. luckyseven += spin[counter];
  135. if (luckyseven == 21)
  136. {
  137. bank += wager * 3;
  138. cout << "CONGRATS YOU WON IT BIG!!!";
  139. }
  140.  
  141. //Check for like numbers
  142. else if (spin[0] == spin[1])
  143. {
  144. bank += wager * 2;
  145. cout << "Congrats, You had two like numbers" << endl;
  146. }
  147. else if (spin[1] == spin[2])
  148. {
  149. bank += wager * 2;
  150. cout << "Congrats, You had two like numbers" << endl;
  151. }
  152. else if (spin[2] == spin[0])
  153. {
  154. bank += wager * 2;
  155. cout << "Congrats, You had two like numbers" << endl;
  156. }
  157. cout << "You currently have $" << bank << endl;
  158. }
  159. }
  160.  
  161. //Bank Ran out
  162. cout << "Dang looks like your lucky streak is over matey. You had " << spincount << " successful winning spins!!" << endl;
  163.  
  164.  
  165. //Hold output
  166. system("pause");
  167.  
  168. //Indicate to OS successful termination of program
  169. return 0;
  170. } //End Main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement