Guest User

Untitled

a guest
Nov 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. char userInput = 0;
  9. srand((unsigned)time(0));
  10. int bank = 25;
  11. int wheelSpin = 0;
  12.  
  13. cout << "Come play \"Spin the Wheel.\" The wheel has numbers from 1-10." << endl << "If you spin an even number you lose that amount. If you spin an"
  14. << endl << "odd number you win that amount. You start with a $25 bank." << endl << endl << "Your bank is $" << bank << " Would you like to spin the wheel? (y/n): ";
  15. cin >> userInput;
  16.  
  17. while(userInput == 'y' || userInput == 'Y')
  18. {
  19. wheelSpin = (rand() % 10) + 1;
  20. if(wheelSpin % 2 == 0)
  21. {
  22. bank += wheelSpin;
  23. cout << "You spun a " << wheelSpin << " and won $" << wheelSpin << endl << "Your bank is now: $" << bank << endl << endl;
  24. if(bank < 10)
  25. {
  26. cout << "You need at least $10 to play this game" << endl;
  27. break;
  28. }
  29. else
  30. {
  31. cout << "Would you like to spin again? (y/n); ";
  32. cin >> userInput;
  33. }
  34.  
  35. }
  36. else
  37. {
  38. bank -= wheelSpin;
  39. cout << "You spun a " << wheelSpin << " and lost $" << wheelSpin << endl << "Your bank is now: $" << bank << endl << endl;
  40. if(bank < 10)
  41. {
  42. cout << "You need at least $10 to play this game" << endl;
  43. break;
  44. }
  45. else
  46. {
  47. cout << "Would you like to spin again? (y/n); ";
  48. cin >> userInput;
  49. }
  50. }
  51. }
  52.  
  53. cout << "Thanks for playing! Come back soon!" << endl;
  54.  
  55. return 0;
  56. }
Add Comment
Please, Sign In to add comment