Question: Write a program that contains various type account classes, and print out various data regarding each account. Create a class named BankAccount. Use the following

Write a program that contains various type account classes, and print out various data regarding each account. Create a class named BankAccount. Use the following starter code

//////////////////////////////////////////////////////////////////////

// class BankAccount

// this is the abstract base class for all types of bank accounts

//////////////////////////////////////////////////////////////////////

class BankAccount

{

public:

BankAccount(int = 0, float = 0);

void deposit(float amount) { bal += amount; }

int account_num() const { return acctnum; }

float balance() const { return bal; }

virtual void print() = 0; //pure virtual function

protected:

int acctnum;

float bal;

};

//////////////////////////////////////////////////////////////////////

// constructor for BankAccounts; both args can default to zero

BankAccount::BankAccount(int num, float ibal)

{

acctnum = num;

bal = ibal;

}

Modify the code by adding two sub classes, Checkings and Savings. -Include Subaccount Constructor. Parameters for each constructor should call the base constructor passing an account number and a starter balance. Include member functions called withdraw for each sub class. Ensure any withdrawal amounts passed in do not exceed the account balance. For checking account, charge a .50 per check fee for any amount going below a 1000 limit. Include a print function for each sub class that when called, displays the account type, account number and account balance. Lastly create 2 deposits and 2 withdrawls for each object named checking and savings. Include for the checking object at least one withdraw outcome that will drop the balance below 1000. Include for the savings object, at least one withdraw that attempts to drop the balance below 0. Your code should disallow this!

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!