Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will practice inheritance and polymorphism. Design a base class named Account which is defined as follows: class Account protected: double balance

image text in transcribed

image text in transcribed

In this assignment, you will practice inheritance and polymorphism. Design a base class named Account which is defined as follows: class Account protected: double balance int number; /I account balance // account number public: Account (double, int) double getBalance ); int getNumber ) void deposit (double) ; void withdraw (double): virtual void display() 0; ):1/ end of class Account The accessor functions, getBalance and getlumber, are self explanatory The deposit function has onde precondition: the amount passed to the function must be positive. The amount passed to the function is added to the current balance after the function is invoked. The withdraw function has the same precondition, plus the amount passed to the function cannot exceed the current balance. That means the current balance must be obtained and compared to the amount passed to the function to derermine f the withdraw function can be called. Invoking the function results in subtracting the amount passed to the function from the current balance. This class also has a pure virtual function In other words, this function cannot be implemented by the dass, but it must be overridden by each of its subclasse Derive two subclasses from this class: SavingsAccount and CheckingAccount The SavingsAccount class has an additional attribute named rate which represents the annual interest rate. The display function of the class displays the balance, account number and the interest rare in percent. On the other hand the CheckingAccount class has no additional attribute: Its display function displays the balance and account number. Both classes are publicly derived from the Account cdlass so that the public member functions of the Account are accessible to the objects of the subclasses ourside the member functions of the subclasses Write a program which has the following menu fot users to interact with the progra

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions