// File: savingAccount.h // savingAccount header file #include "account.h" class savingAccount : public account // this is inherited from account { protected: double rate; // decimal periodic interest rate public: savingAccount(double bal, double pct); double compound(void); // compute and deposit interests double withdraw(double amt); }; // File: savingAccount.cpp // implementation file for the savingAccount class #include "savingAccount.h" savingAccount::savingAccount(double bal, double pct) : account(bal) { rate = pct / 100.0; } double savingAccount::compound(void) { double interest = rate * balance; balance += interest; return interest; } double savingAccount::withdraw(double amt) { if (amt <= balance) { balance -= amt; return amt; } else return 0; } // File: checkingAccount.h // header file for the checkingAccount class #include "account.h" class checkingAccount : public account // inherits from account class { protected: double limit; // lower limit for free checking double charge; // per-check charge for low balance public: checkingAccount(double bal, double lim, double chg); double cashCheck(double amt); }; // File: checkingAccount.cpp // implementation file for class checkingAccount #include "checkingAccount.h" checkingAccount::checkingAccount( double bal, double lim, double chg) : account( bal ) { limit = lim; charge = chg; } double checkingAccount::cashCheck(double amt) { if ((balance < limit) && (amt + charge <= balance)) { balance -= amt + charge; return amt + charge; } else if ((balance >= limit) && (amt <= balance)) { balance -= amt; return amt; } else return 0.0; }