Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this lab assignment, using polymorphism. Starting with create a class Bank , this will be the base class in this project. The private data

In this lab assignment, using polymorphism. Starting with create a class Bank , this will be the base class in this project. The private data of this class will be vector of bank accounts. Each bank account will contain the account number (random 4digit integer), account type (saving or checking), and balance of the account. The base class and Account can be declared as suggested in the follows:

enum account_type {saving, checking} class Account { public: Account () ~Account() private: int account_number account_type type double balance }

class Bank { public: Bank() ~Bank() // additional functions as needed virtual void deposit() = 0 virtual void withdraw() = 0 private: vector bank_accounts }

Create 2 other derived classes from the base class called Saving and Checking. Redefine the deposit and withdraw functions for each class as follow:

For Saving class when call deposit function, a new amount (can be zero) will be added to the current balance along with the interest from the original balance when call withdraw function, check if the amount is valid (cannot exceed the current balance)

For Checking class when call deposit function, a new amount (cannot be zero) will be added to the current balance a transaction fee will be subtracted from the balance. when call withdraw function, check if the amount is valid (cannot exceed the current balance minus the transaction fee) withdraw the amount and subtract the transaction fee from the balance. When making the bank accounts, the account numbers will be the random 4digit integers the initial balances will be the random double value between $0 and $100.00 the account type will be either saving or checking.

The interest rate will be 0.01 for all saving accounts. The transaction rate will be $0.50 for all checking account. Start the program by making 5 random accounts. The following is the sample inputs and outputs

Select the following options 1. Add new account 2. Deposit to an account 3. Withdraw from an account 4. Print all accounts 5. Quit 4 Account number Type Balance 1123 Saving 23.45 5432 Checking 54.65 7421 Checking 87.34 2376 Saving 65.76 5341 Checking 65.34

Select the following options 1. Add new account 2. Deposit to an account 3. Withdraw from an account 4. Print all accounts 5. Quit 1

Enter account number: 1111 Enter account type: Saving Enter account balance: 123

Account number Type Balance 1123 Saving 23.45 5432 Checking 54.65 7421 Checking 87.34 2376 Saving 65.76 5341 Checking 65.34 1111 Saving 123.00

Select the following options 1. Add new account 2. Deposit to an account 3. Withdraw from an account 4. Print all accounts 5. Quit 2

Enter account number: 2376 Enter amount: 50 Deposit $50.00 to Saving account 2376, the new balance is $116.41

Select the following options 1. Add new account 2. Deposit to an account 3. Withdraw from an account 4. Print all accounts 5. Quit 3

Enter account number: 7421 Enter amount: 50 Withdraw $50 from Checking account 7421, the new balance is $36.84

Select the following options 1. Add new account 2. Deposit to an account 3. Withdraw from an account 4. Print all accounts 5. Quit 5 Program terminated

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_2

Step: 3

blur-text-image_3

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

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions

Question

Know the ethical issues and consequences of downsizing.

Answered: 1 week ago