Question: Please code this in C + + following the directions and output exactly as shown in the brief outline and expected output in the images.
Please code this in C following the directions and output exactly as shown in the brief outline and expected output in the images. The following is a skeleton code to be built around that.
SKELETON CODE:
#include
#include
using namespace std;
Constants
const int MINBANKSIZE ;
const int MAXBANKSIZE ;
const string DASHES ;
const string BANKMSG "Please enter the size of the bank";
const string COINSMSG "Please enter the number of coins you would like to play or ;
const string AGAINMSG "Would you like to play again? yn;
const string PLAYEDMSG "Total games played : ;
const string INTREADERRMSG "Invalid number, please try again";
const string CHARREADERRMSG "Invalid choice. Please type y for yes or n for no;
This program is intended to give some practice with iteration for and while loops
You are asked to implement the game described in the accompanying pdf
Please use the pdf and the description comments to implement the game
int main
YOUR CODE HERE
Prompt the user and ask for the bank size using the provided variable
Error check the bankSize variable to make sure it is between the min and max size. If not, print an error message
If the entered value is incorrect, reprompt the user until they enter a valid number
HINT: Remember that fail can be used to check for bad reads. The read must succeed before we can even
check if it is in bounds
int bankSize ;
The following code is provided for you for reference. The code prints the initial bank to the screen.
Consider copypasting and modifying this code to fit your needs
cout "Initial Bank bankSize endl; Print header
for int row ; row bankSize; rowRepeat the code as many times as there are rows in the piggy bank
cout endl; Print each row of the piggy bank left wall, middle, right wall in the for loop
cout endl endl; Print the bottom of the piggy bank after the for loop is done
YOUR CODE HERE
Create any variables you think you need to play the game
Below is one possible algorithm for playing the gameinstructor solution You are encouraged to try and think of your own solution
before using the below description. Your solution does not need to be the same, the below is only a suggested strategy.
It is recommended to start with tasks at the smallest scope biggest indent in suggested strategy test, and work your way
outwards. That is try to solve the subproblems or shorter pieces of code like getting the number of coins a player
wants to play or printing messages before adding the loop that repeats that code. Try doing one player turn first and then
worry about repeating player turns and playing multiple games!
While the user wants to keep playing, keep playing the game
Set up the game by initializing gamerelated variables
Play the game until someone wins
Player Turn
Print whose turn it is Player or Player
Ask the player to enter the number of coins they want to put into the bank
Read the number from the player. Repeat asking and reading until they enter a valid number of coins or
After the player enters a valid number of coins, add those coins to the bank
Print the state of the bank
Check if the player won. If so end the game
If they're still playing, change whose turn it is Player Player
When the game is done, print a message saying which player won and end the game
Count the game as finished and add to the count of total games played
Once the game is over, ask if they want to play again. If not, stop playing
Prompt the user if they want to play again
Error check their input. They must enter a y for yes or n for no
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
