Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions