Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. In the following program the bank account classes from question 2 are used. (a) Run the program using the input le transactionsin.txt, choose the

4. In the following program the bank account classes from question 2 are used.

(a) Run the program using the input le transactionsin.txt, choose the chequeing account when prompted. Does the program work properly?

(b) Make the necessary methods in the class account virtual. Does the program work properly?

(c) Make the necessary change to the processtransactions function prototype so that the program works properly. image text in transcribed

image text in transcribed image text in transcribed

image text in transcribed

Declaration of Classes AccountsTransactions File accountstransactions.h #ifnd ef ACCUNTSTRANSACTIONS.H #define ACCOUNTSTRANSACTIONS.H #include #include #include using namespace std; class account { private: string owner float balance float withdrawfee; public: account (string name, float fee) void write (ostream & out) const; void deposit (float amount); bool withdraw (float amount); float getbalance (void) const; float getwithdrawfee (void) const; class savingsaccount public account private: float interestrate; public: savingsaccount (string name, float fee, float rate); void write (ostream & out) const; void addinterest (void); class chequingaccount public account { private: int remainingfreewithdrawals; public: chequingaccount (string name, float fee, int numberfree); void write (ostream & out) const; bool withdraw ( float amount); void processtransactions (account x); #endif /* ACCOUNTSTRANSACTIONS.H */ Implementation of Classes AccountsTransactions File accountstransactions cpp Implementation of classes accountstransactions/ #include accountstransactions.h" account : account (string name, float fee) ownername; balance = 0; withdrawfeefee; void account:: write (ostream & out) const out balance-withdrawfee) cout type >amount) I if (type w') x. withdraw (amount); cout > type; if (type '' processtransactions (s) if (type ) processtransactions (c); return 0 /Program output: Which account to process? (c or s)c deposit 100 owner: bob balance 100 withdrawfee 0.5 remaing free withdrawals 2 withdraw 10 owner bob balance: 90 withdrawfee 0.5 remaing free withdrawals 1 withdraw 5 owner: bob balance: 85 withdrawfee 0.5 remaing free withdrawals 0 withdraw 20 owner: bob balance: 64.5 withdrawfee 0.5 remaing free withdrawals 0 deposit 10 owner bob balance: 74.5 withdrawfee 0.5 remaing free withdrawals: 0 withdraw 30 owner: bob balance: 44 withdrawfee 0.5 remaing free withdrawals: (0 Which account to process? (c or s) :s deposit 100 owner: joe balance 100 withdrawfee 0.5 interest rate 0.03 withdraw 10 owner: joe balance: 89.5 withdrawfee 0.5 interest rate 0.03 withdraw 5 owner: joe balance 84 withdrawfee 0.5 interest rate 0.03 withdraw 20 owner: joe balance: 63.5 withdrawfee 0.5 interest rate 0.03 deposit 10 owner: joe balance: 73.5 withdrawfee 0.5 interest rate 0.03 withdraw 30 owner: joe balance: 43 withdrawfee 0.5 interest rate 0.03 Declaration of Classes AccountsTransactions File accountstransactions.h #ifnd ef ACCUNTSTRANSACTIONS.H #define ACCOUNTSTRANSACTIONS.H #include #include #include using namespace std; class account { private: string owner float balance float withdrawfee; public: account (string name, float fee) void write (ostream & out) const; void deposit (float amount); bool withdraw (float amount); float getbalance (void) const; float getwithdrawfee (void) const; class savingsaccount public account private: float interestrate; public: savingsaccount (string name, float fee, float rate); void write (ostream & out) const; void addinterest (void); class chequingaccount public account { private: int remainingfreewithdrawals; public: chequingaccount (string name, float fee, int numberfree); void write (ostream & out) const; bool withdraw ( float amount); void processtransactions (account x); #endif /* ACCOUNTSTRANSACTIONS.H */ Implementation of Classes AccountsTransactions File accountstransactions cpp Implementation of classes accountstransactions/ #include accountstransactions.h" account : account (string name, float fee) ownername; balance = 0; withdrawfeefee; void account:: write (ostream & out) const out balance-withdrawfee) cout type >amount) I if (type w') x. withdraw (amount); cout > type; if (type '' processtransactions (s) if (type ) processtransactions (c); return 0 /Program output: Which account to process? (c or s)c deposit 100 owner: bob balance 100 withdrawfee 0.5 remaing free withdrawals 2 withdraw 10 owner bob balance: 90 withdrawfee 0.5 remaing free withdrawals 1 withdraw 5 owner: bob balance: 85 withdrawfee 0.5 remaing free withdrawals 0 withdraw 20 owner: bob balance: 64.5 withdrawfee 0.5 remaing free withdrawals 0 deposit 10 owner bob balance: 74.5 withdrawfee 0.5 remaing free withdrawals: 0 withdraw 30 owner: bob balance: 44 withdrawfee 0.5 remaing free withdrawals: (0 Which account to process? (c or s) :s deposit 100 owner: joe balance 100 withdrawfee 0.5 interest rate 0.03 withdraw 10 owner: joe balance: 89.5 withdrawfee 0.5 interest rate 0.03 withdraw 5 owner: joe balance 84 withdrawfee 0.5 interest rate 0.03 withdraw 20 owner: joe balance: 63.5 withdrawfee 0.5 interest rate 0.03 deposit 10 owner: joe balance: 73.5 withdrawfee 0.5 interest rate 0.03 withdraw 30 owner: joe balance: 43 withdrawfee 0.5 interest rate 0.03

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

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions

Question

Explain class distinctions in the United States and India.

Answered: 1 week ago