Guest User

Untitled

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