Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- int main()
- {
- int randomSpin = 0;
- int bank = 25;
- char userInput = 0;
- srand((unsigned)time(NULL));
- cout << "Come play \"Spin the Wheel.\" The wheel has numbers from 1-10." << endl;
- cout << "If you spin an even number you lose that amount." << endl;
- cout << "If you spin an odd number you win that amount." << endl;
- cout << "You start with a $25 bank." << endl << endl;
- cout << "Your bank is $" << bank << " Would you like to spin the wheel? (y/n): ";
- cin >> userInput;
- while(userInput == 'Y' || userInput == 'y')
- {
- randomSpin = (rand() % 10) + 1;
- if(bank < 10)
- {
- cout << "You need at least $10 to play this game" << endl;
- cout << "Thanks for playing! Come back soon!" << endl;
- return 0;
- }
- if(randomSpin % 2 == 0)
- {
- bank += randomSpin;
- cout << "You spun a " << randomSpin << " and won $" << randomSpin << " !" << endl << "Your bank is now: $" << bank << endl << endl;
- cout << "Would you like to spin again? (y/n); ";
- cin >> userInput;
- }
- else
- {
- bank -= randomSpin;
- cout << "You spun a " << randomSpin << " and lost $" << randomSpin << " !" << endl << "Your bank is now: $" << bank << endl << endl;
- cout << "Would you like to spin again? (y/n); ";
- cin >> userInput;
- }
- }
- cout << "Thanks for playing! Come back soon!" << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment