Question: Week 10 CPSC 120 Week 10 Adding Class to Your Programs Lab+ Homework 10 - Piggy Bank ATM 2 Although Mr. Pigglesworth Bank has been
Week 10 CPSC 120 Week 10 Adding Class to Your Programs Lab+ Homework 10 - Piggy Bank ATM 2 Although Mr. Pigglesworth Bank has been your trusted piggy bank since age 5, you have had enough Pigglesworth into the moderm era by programming an ATM application for your piggy bank. To model your piggy bank, you will define a class called Coins, which contains four integer members: quarters, dimes, nickels, and pennies. You will also define several member functions that will help you work with your Coins instances of the establishment's antiquated style of service. You have decided to bring Mr. When your program is launchedit does the following. 1) It creates a Coin instance called piggyBank that contains 5 quarters, 10 dimes, 15, nickels, and 20 pennies. Hint: Use a constructor The program calls ShowMenu) to display a menu of 5 choices: D' for depositing coins in bank, W" for withdrawing coins from bank, 'S' for showing the account balance, and 'Q' for quitting the program. The program then waits for the user to make a choice. 2) The program proceeds to carry out the action the user selected. a. If D'or 'd' was selected, Coins member function EnterCoins) is called on an Coins 3) instance called amount to ask the user to specify how much of each type of coin should be deposited. Assume that the user always has the amount of coins they wish to deposit Coins member function DepositCoins (Coins amount) is then called on piggyBank to deposit amount's quantity of coins before returning to step 2 b. If W or w' was selected, Coins member function EnterCoins) is called on a Coins instance called amount to ask the user to specify how much of each type of coin should be withdrawn from piggyBank. The Coins member function CoinsAvailable(Coins amount) is called on piggyBank to determine if the user is attempting to withdraw more coins than the bank contains. If the user is attempting to take more coins than the bank contains, the program cancels the transaction and displays an error message; otherwise Coins member function WithdrawCoins(Coins amount) is called on piggyBank to remove the appropriate amount of coins from piggyBank. Either way, program returns to step 2 If 'S'or 's' was selected, the user is shown the quantities for each kind of coin in piggyBank. Program returns to step 2 c. d. if 'Q'or 'q' was selected, the program quits. e. If none of the above actions were selected, an error message is displayed before returning to step 2 Requirements 1) The program must define a class called Coins that contains four private integer data members: quarters, dimes, nickels, and pennies
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
