Question
Assignment You will be writing a program to simulate a slot machine. The player will start with $1000 and you will repeatedly ask the user
Assignment
You will be writing a program to simulate a slot machine. The player will start with $1000 and you will repeatedly ask the user how much money they wish to insert into the machine before spinning, or allow the player to quit. If the player runs out of money, the game is over. Additionally, the player cannot spend more money than they have available. You should store the player's wagers and winnings in order to output statistics when the user is done playing.
Spinning and Payouts
After placing a bet, the money is immediately subtracted from the player's balance. The slot machine has 3 reels which are spun after the lever is pulled. Each reel will randomly contain a integer value between 2 and 7 inclusive after being spun. If all 3 reels have the value 7, the player obtained a jackpot and will receive the amount which they wagered times 10. If all 3 reels match, but contain a value other than 7, award the player their wagered amount times 5. Otherwise, if only 2 reels match, award the player their wager times 2. If none of the reels match, the player does not receive any earnings.
Restrictions / Hints
1. At the start, ask the user for a seed to use for the random number generator. Use this value to seed your random numbers. You must use functionality from the library such as default_random_engine and uniform_int_distribution. You should not use other methods from other libraries such as rand or srand.
2. Before each spin, show the user their current balance and ask for a wager.
3. The slot machine only accepts wagers containing whole dollar amounts. You may not enter any spare change.
4. You must use an array to store the value of each reel.
5. You must use a for loop to input the random values of each reel.
6. You must use a vector to store the amount of each wager.
7. You must use a vector to store the winnings of each spin.
8. You must perform error checking on user input. See examples for handling invalid user input.
9. You may not create any functions (if you know how).
10. If the user wagers an amount of 0 or less, stop playing and output play statistics. Additionally, if the user has a balance of $0 and is unable to wager, end the game and output play statistics. If the user never played and walks away immediately, do not output any statistics.
11. At the end, output a summary of each spin including the wager and amount won. Then output the smallest and largest wager, and the smallest non-zero winnings and the largest winnings from a single spin. Note that if the user never wins, the smallest and largest winnings displayed should be 0.
Examples
Text in red is user input.
Input a seed: 102 Your money: $1000 Place a bet: $50 2 4 2 You won $100! Your money: $1050 Place a bet: $100 6 4 4 You won $200! Your money: $1150 Place a bet: $50 6 3 3 You won $100! Your money: $1200 Place a bet: $300 4 2 7 You didn't win. Your money: $900 Place a bet: $0 You wagered $50 and won $100. You wagered $100 and won $200. You wagered $50 and won $100. You wagered $300 and won $0. Your smallest wager was $50. Your largest wager was $300. Your smallest winnings was $100. Your largest winnings was $200.
Input a seed: YBMAZ Input a seed: 3 Your money: $1000 Place a bet: $ZAMBY Place a bet: $1001 Place a bet: $1.99 2 4 3 You didn't win. Your money: $999 Place a bet: $Place a bet: $2 4 5 5 You won $4! Your money: $1001 Place a bet: $3 2 2 2 You won $15! Your money: $1013 Place a bet: $4 6 2 5 You didn't win. Your money: $1009 Place a bet: $-420 You wagered $1 and won $0. You wagered $2 and won $4. You wagered $3 and won $15. You wagered $4 and won $0. Your smallest wager was $1. Your largest wager was $4. Your smallest winnings was $4. Your largest winnings was $15.
Input a seed: 130 Your money: $1000 Place a bet: $1000 2 2 3 You won $2000! Your money: $2000 Place a bet: $2000 5 3 4 You didn't win. You are out of money! You wagered $1000 and won $2000. You wagered $2000 and won $0. Your smallest wager was $1000. Your largest wager was $2000. Your smallest winnings was $2000. Your largest winnings was $2000.
Input a seed: 140 Your money: $1000 Place a bet: $0 You walked away without playing.
Please help me, I would greatly appreciate it. This is due tomorrow at midnight. Use #include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started