write a C++ prgram for a game called \"Three Strikes and You Are Out\". Three St
ID: 3687674 • Letter: W
Question
write a C++ prgram for a game called "Three Strikes and You Are Out". Three Strikes is a popular game played for winning a car. There are five chips, each with one of the digits of the price of the car, and three chips with X’s (strikes). All the digits of the price are different and unique (only one of its kind). The eight chips are placed in a bag. The contestant picks chips from the bag one by one. If the contestant picks a digit, she/he must guess which position in the price of the car the digit belongs. If she/he is right, the digit lights up on the board, and the digit is discarded from the bag. If not, the digit is placed back in the bag. If the contestant should pick a strike, the strike is removed from the bag. The contestant wins if she/he fills out the price of the car before picking out all three strikes. Requirements: 1.You cannot pick a digit that was not in the price of the car. It's impossible to do that. 2.After each pick, the number of strikes hit and the number of digits correctly placed must be shown on screen. 3.And there must be a panel displayed to show the process of the game, locating the digits that were answered correct. 4.At the end, regardless of losing or winning the game, the price of the car must be displayed on screen.
Explanation / Answer
a C++ prgram for a game called "Three Strikes and You Are Out". Three Strikes is a popular game played for winning a car. There are five chips, each with one of the digits of the price of the car, and three chips with X’s (strikes). All the digits of the price are different and unique (only one of its kind). The eight chips are placed in a bag. The contestant picks chips from the bag one by one. If the contestant picks a digit, she/he must guess which position in the price of the car the digit belongs. If she/he is right, the digit lights up on the board, and the digit is discarded from the bag. If not, the digit is placed back in the bag. If the contestant should pick a strike, the strike is removed from the bag. The contestant wins if she/he fills out the price of the car before picking out all three strikes.
Requirements: 1.You cannot pick a digit that was not in the price of the car. It's impossible to do that. 2.After each pick, the number of strikes hit and the number of digits correctly placed must be shown on screen. 3.And there must be a panel displayed to show the process of the game, locating the digits that were answered correct. 4.At the end, regardless of losing or winning the game, the price of the car must be displayed on screen
Program:
sample output:
Sample Run
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-
*********** Welcome to Three Strikes Game ***********
Pick a chip from a bag, the chip will contain
a digit or a strike, if it's a digit then guess
which position it belongs to the car's price
PANEL : _ _ _ _ _ <- this is the 0th position
POSITION: 4 3 2 1 0
Accumulating three strikes will result in losing the game.
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-^-~-
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
| Strikes hit: 0 |
| Digits placed: 0 |
| |
| Panel: $ _ _ _ _ _ |
| 4 3 2 1 0 |
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
Enter 'p' to pick a chip, or any other key to quit the game: p
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
| Strikes hit: 0 |
| Digits placed: 0 |
| |
| Panel: $ _ _ _ _ _ |
| 4 3 2 1 0 |
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
You picked the digit: 7
Which position do you think it is? p
Invalid position, input the position again:
Invalid position, input the position again:
3
Sorry! You guessed the wrong position
Enter 'p' to pick a chip, or any other key to quit the game: p
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
| Strikes hit: 0 |
| Digits placed: 0 |
| |
| Panel: $ _ _ _ _ _ |
| 4 3 2 1 0 |
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
You picked the digit: 0
Which position do you think it is? 1
Sorry! You guessed the wrong position
Enter 'p' to pick a chip, or any other key to quit the game: p
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
| Strikes hit: 0 |
| Digits placed: 0 |
| |
| Panel: $ _ _ _ _ _ |
| 4 3 2 1 0 |
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
You picked the digit: 2
Which position do you think it is? 7
Sorry! You guessed the wrong position
Enter 'p' to pick a chip, or any other key to quit the game: p
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
| Strikes hit: 0 |
| Digits placed: 0 |
| |
| Panel: $ _ _ _ _ _ |
| 4 3 2 1 0 |
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
You picked the digit: 1
Which position do you think it is? 1
Sorry! You guessed the wrong position
Enter 'p' to pick a chip, or any other key to quit the game: p
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
| Strikes hit: 0 |
| Digits placed: 0 |
| |
| Panel: $ _ _ _ _ _ |
| 4 3 2 1 0 |
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
You picked the digit: 5
Which position do you think it is? 4
Correct, you picked the correct position!!!
Enter 'p' to pick a chip, or any other key to quit the game: p
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
| Strikes hit: 0 |
| Digits placed: 1 |
| |
| Panel: $ 5 _ _ _ _ |
| 4 3 2 1 0 |
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
You picked a strike!!!
Enter 'p' to pick a chip, or any other key to quit the game: 5
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
| Strikes hit: 1 |
| Digits placed: 1 |
| |
| Panel: $ 5 _ _ _ _ |
| 4 3 2 1 0 |
~-^-~-^-~-^-~-^-~-^-~-^-~-^-~
Sorry, you lost the game!
The price of the car was: $50721
Do you want to play again (y/n)?
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.