Question: Use C++ programing this is all the information I have /* * This class model a piggy bank to which pennies, nickels, dimes, * and

Use C++ programing this is all the information I have

/* * This class model a piggy bank to which pennies, nickels, dimes, * and quarters can be added. A PiggyBank object maintains how many * of each coin it holds and can tell you the total money in it. * * File name: PiggyBank.h (available on this book's website) */ class PiggyBank { public: PiggyBank(); // post: An PiggyBank is built with no coins void addPennies(int penniesAdded); // pre: penniesAdded > 0 // post: This PiggyBank has penniesAdded more pennies void addNickels(int nickelsAdded); // pre: nickelsAdded > 0 // post: This PiggyBank has nickelsAdded more nickels void addDimes(int dimesAdded); // pre: dimesAdded > 0 // post: This PiggyBank has dimesAdded more dimes void addQuarters(int quartersAdded); // pre: quartersAdded > 0 // post: This PiggyBank has quartersAdded more quarters double drainTheBank(); // post: Remove all of the coins from this PiggyBank // and returns how much there was before it was emptied //-- Accessors int getPennies(); // post: Return the total number of pennies in this bank int getNickels(); // post: Return the total number of nickels in this bank int getDimes(); // post: Return the total number of dimes in this bank int getQuarters(); // post: Return the total number of quarters in this bank double getTotalCashInBank(); // post: return the total cash in the bank. Pennies are // $0.01, nickels are $0.05, dimes are $0.10, and quarters // are $0.25 (no half or one dollar coins). private: int pennies, nickels, dimes, quarters; }; 
#include  using namespace std; #include "PiggyBank.h" int main() { PiggyBank pb; cout  

Copies of PiggyBank .h and 6C_ piggyBankTestDriver.cpp are attached above.

You will need to write the PiggyBank.cpp file.

PiggyBank.h has 11 functions (one constructor, 5 modifier and 5 accessor functions which are const).

Copy these 11 function declarations to a new file called PiggyBank.cpp.

Be sure to add at the top of the file: your name #include using namespace std; #include "PiggyBank.h"

Add the name of the class and the scope resolution operator before each function and { } at the end PiggyBank::PiggyBank() { } // constructor has no return type void PiggyBank::addPennies(int penniesAdded) { }

You are now ready to write the function code for each class function.

Make sure you add both PiggyBank .cpp and 6D_ piggyBankTestDriver.cpp to the Visual Studio, Solution Explorer, Source Files folder.

Don't forget to set all private data (see list in .h file) to a 0 value in the constructor.

Submit the main program with your output,

Activity 6.3 input/output:

/* Student Name, CIS127, Assignment 2.1 Cash in the pig : 0.00 Number of pennies : 4 Number of nickles : 3 Number of dimes : 2 Number of quarters : 1 Cash in the pig : 0.64 Cash before draining : 0.64 Cash after draining : 0.00 Press any key to continue . . .*/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!