0% found this document useful (0 votes)
42 views2 pages

#Include #Include Using Namespace Class Protected Float Public

This C++ code defines three classes for different types of bank accounts: a base cBankAct class with deposit and withdraw methods, a derived cCheckingAct class that adds transaction counting to withdrawals, and a cSavingsAct class. It then creates two cCheckingAct objects, performs various deposit and withdrawal transactions on them, with one withdrawal incurring an extra fee due to exceeding the transaction limit.

Uploaded by

Tayyab Ali
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

#Include #Include Using Namespace Class Protected Float Public

This C++ code defines three classes for different types of bank accounts: a base cBankAct class with deposit and withdraw methods, a derived cCheckingAct class that adds transaction counting to withdrawals, and a cSavingsAct class. It then creates two cCheckingAct objects, performs various deposit and withdrawal transactions on them, with one withdrawal incurring an extra fee due to exceeding the transaction limit.

Uploaded by

Tayyab Ali
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<iostream> #include<conio.

h> using namespace std; class cBankAct { protected: float Balance; public: cBankAct() { Balance = 1000; } cBankAct(float Amt){ Balance = Amt; } void depositMoney(float Amt) { Balance+= Amt; } void withdrawMoney(float Amt) { Balance -= Amt; } }; class cCheckingAct : public cBankAct { private: float numberofTransactions; public: cCheckingAct():cBankAct() //Default Construction { numberofTransactions = 0; }; cCheckingAct(float Amount):cBankAct(Amount) Constructor { numberofTransactions = 0; };

//Parameterized

void withdrawMoney(float Amt) { numberofTransactions ++; if(numberofTransactions > 3) Amt+=.5; if(Amt > Balance){ cout << "Insufficient funds for transaction. Canceling..."; return; } Balance -= Amt; } }; class cSavingsAct :public cBankAct {

private: float dailyInterestRate; //Whatever else public: };

void main() { cCheckingAct BobJohn(45000); cCheckingAct JaneDoe; JaneDoe.withdrawMoney(45); JaneDoe.depositMoney(90); BobJohn.withdrawMoney(90000); _getch();

You might also like