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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started