Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is simply out of curiosity. I wrote a code for a class and remembered last semester we used UML diagrams and we haven't used

This is simply out of curiosity. I wrote a code for a class and remembered last semester we used UML diagrams and we haven't used them since and for this code particularly I wanted to see how everything is connected and was hoping someone could create a UML diagram for this code, please and thank you

#include #include using namespace std;

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;

protected: int acctnum; float bal; }; BankAccount::BankAccount(int num, float ibal) { acctnum = num; bal = ibal; }

const float MIN_BALANCE = 1000.00; const float SERVICE_CHARGE = 0.005;

class checkingAccount : public BankAccount { public: void withdraw(float amount); void print(); checkingAccount(int acctNumber, float _bal);

protected: float minimumBalance; }; checkingAccount::checkingAccount(int acctNumber, float _bal) : BankAccount(acctNumber, _bal) { acctnum = acctNumber; bal = _bal; minimumBalance = MIN_BALANCE; } void checkingAccount::withdraw(float amount) { float serviceCharge = SERVICE_CHARGE * amount; if (bal - amount < 0) cout << "Not enough money in the account." << endl; else if (bal - amount < minimumBalance) { if (bal - amount - serviceCharge < 0) { cout << "After this transaction, the balanace will be " << "below the minimum balance." << endl << "However account does not have enough money " << "to process the transaction and apply service charge." << endl << "Transaction denied!" << endl; } else { cout << "After this transaction, the balanace will be " << "below the minimum balance." << endl << "Service charges will apply." << endl; bal = bal - amount - serviceCharge; cout << fixed << setprecision(2) << amount << " successfully withdrawn and Service charges of " << serviceCharge << " are levied "; } } else { bal = bal - amount; cout << fixed << setprecision(2) << amount << " successfully withdrawn "; } } void checkingAccount::print() { cout << fixed << setprecision(2); cout << "Account Type: Checking Account " << "Account Number: " << acctnum << " " << "Balance: " << bal << " "; }

class savingsAccount : public BankAccount { public: savingsAccount(int acctNumber, double _bal); void withdraw(double amount); void print();

protected: double minimumBalance; }; savingsAccount::savingsAccount(int acctNumber, double _bal) : BankAccount(acctNumber, _bal) { minimumBalance = MIN_BALANCE; } void savingsAccount::withdraw(double amount) { if (bal - amount < 0) { cout << "Insufficient balance. Transaction denied! "; } else if (bal - amount < minimumBalance) { cout << "After this transaction, the balanace will be " << "below the minimum balance." << endl << "Transaction denied!!." << endl; } else { bal -= amount; cout << fixed << setprecision(2) << amount << " successfully withdrawn "; } } void savingsAccount::print() { cout << fixed << setprecision(2); cout << "Account Type: Savings Account " << "Account Number: " << acctnum << " " << "Balance: " << bal << " "; }

// driver function int main() { checkingAccount c(5678, 3000); savingsAccount s(1234, 2000);

cout << " Withdrawing 1000 from Checking Account.... "; c.withdraw(1000); cout << " Withdrawing 1500 from Checking Account.... "; c.withdraw(1500);

cout << " Withdrawing 500 from Savings Account.... "; s.withdraw(500); cout << " Withdrawing 1000 from Savings Account.... "; s.withdraw(1000);

BankAccount *accounts[2]; accounts[0] = &c; accounts[1] = &s; cout << " "; for (int i = 0; i < 2; i++) { accounts[i]->print(); }

return 0; }

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

Discuss the techniques of job analysis.

Answered: 1 week ago

Question

How do we do subnetting in IPv6?Explain with a suitable example.

Answered: 1 week ago

Question

Explain the guideline for job description.

Answered: 1 week ago

Question

What is job description ? State the uses of job description.

Answered: 1 week ago

Question

What are the objectives of job evaluation ?

Answered: 1 week ago