Question: I wrote a c++ program for this question, but I don't know how to write the next step. #include #include using namespace std; class Account{

I wrote a c++ program for this question, but I don't know how to write the next step.

#include #include using namespace std;

class Account{ public: Account(double); virtual void credit(double); virtual bool debit(double); void setBalance(double); double getBalance(); private: double balance; }; Account::Account(double initialBalance){ if(initialBalance>=0.0) balance=initialBalance; else coutbalance){ coutaccount(2); double interest; double withdraw=500.5; double deposit=200.5; account[0]=new SavingAccount(1000,0.5); account[1]=new CheckingAccount(1000,0.7); account[0]->debit(withdraw); account[1]->credit(deposit); return 0; }

I wrote a c++ program for this question, but I don't know

12.14 (Polymorphic Banking Program using Account Hierarchy) Develop a polymorphic banking program using the Account hierarchy created in Exercise 11.10. Create a vector of Account pointers to savingsAccount and CheckingAccount objects. For each Account in the vector , allow the user to specify an amount of money to withdraw from the Account using member function debit and an amount of money to deposit into the Account using member function credit. As you process each Account , determine its type. If an Account is a savingsAccount , calculate the amount of interest owed to the Account using member function calculateInterest , then add the interest to the account balance using member function credit. After processing an Account, print the updated account balance obtained by invoking base-class member function getBalance

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!