Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have made all the fucntions and the classes but I am having trouble creating t

ID: 3908627 • Letter: I

Question

I have made all the fucntions and the classes but I am having trouble creating the Driver Function. Please I need help wth that ASAP

In your driver, create a vector of six Account pointers (alternating Checking then Saving, etc.) For each account, allow the user to deposit and withdraw from the account using the appropriate member functions. As you process each account, determine its type. If it is a SavingsAccount, calculate and add interest after the deposit. After processing each account, print the updated balance by invoking the base-class member function getBalance.

Explanation / Answer

Please find a sample driver code.

int main() {

vector<Account*> accounts;

// push alternate Checking and Savings Account

accounts.push_back(new CheckingAccount());

accounts.push_back(new SavingsAccount());

accounts.push_back(new CheckingAccount());

accounts.push_back(new SavingsAccount());

accounts.push_back(new CheckingAccount());

accounts.push_back(new SavingsAccount());

for(int i=0; i<6; i++) {

// Call deposit and withdraw from each account

// you can have a menu to get the user choice and then perform

// operation accordingly. For time being, i am calling both

// withdraw and deposit

accounts[i]->withdraw(3000);

accounts[i]->deposit(2000);

if(i % 2 != 0) {

// add interest here for the SavingsAccount

}

// Finnaly call getBalance() to get the final balance

cout << "Updated account balance: $" << accounts[i]->getBalance();

}

}

NOTE: You might need to make changes to it as per your requirements and class name.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote