Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ Note: I have included the codes I used previously. Please assist with labeling each code please. Codes used below bankAccount .cpp #include bankAccount.h //bankAccount::bankAccount()

c++

Note: I have included the codes I used previously. Please assist with labeling each code please.

image text in transcribed

image text in transcribed

image text in transcribed

Codes used below

bankAccount.cpp

#include "bankAccount.h"

//bankAccount::bankAccount() //{ //}

bankAccount::bankAccount(string acctNum, double startBal) { accountNumber = acctNum; balance = startBal; }

//bankAccount::~bankAccount() //{ //}

double bankAccount::deposit(double depositAmt) { balance += depositAmt; return balance; }

string bankAccount::getAccountNumber() { return accountNumber; }

double bankAccount::getBalance() { return balance; }

void bankAccount::print() { cout

void bankAccount::setAccountNumber(string acctNum) { accountNumber = acctNum; }

double bankAccount::withdraw(double withdrawalAmt) { balance -= withdrawalAmt; return balance; }

ba nkAccount.h

#ifndef BANKACCOUNT_H #define BANKACCOUNT_H #include #include using namespace std;

class bankAccount { protected: string accountNumber; double balance;

public: //bankAccount(); bankAccount(string acctNum, double startBal); //~bankAccount(); double deposit(double depositAmt); string getAccountNumber(); double getBalance(); void print(); void setAccountNumber(string acctNum); double withdraw(double withdrawalAmt); };

#endif // !BANKACCOUNT_H

checkingAccount.cpp

#include "checkingAccount.h"

//checkingAccount::checkingAccount() //{ //}

checkingAccount::checkingAccount(string acctNum, double startBal, double intRate, double minBalance, double srvCharge) : bankAccount(acctNum, startBal) { //bankAccount::accountNumber = acctNum; //bankAccount::balance = startBal; interestRate = intRate; minimumBalance = minBalance; serviceCharge = srvCharge; }

//checkingAccount::~checkingAccount() //{ //}

double checkingAccount::getInterestRate() { return interestRate; }

double checkingAccount::getMinimumBalance() { return minimumBalance; }

double checkingAccount::getServiceCharge() { return serviceCharge; }

// Multiplies balance times interest rate (as percentage) divided by 100, adds interest to balance, // and returns interest gained double checkingAccount::postInterest() { if (balance

void checkingAccount::print() { cout

void checkingAccount::setInterestRate(double intRate) { interestRate = intRate; }

void checkingAccount::setMinimumBalance(double minBalance) { minimumBalance = minBalance; }

void checkingAccount::setServiceCharge(double srvCharge) { serviceCharge = srvCharge; }

// returns true if balance is below minimum balance bool checkingAccount::verifyMinimumBalance() { bool balanceBelow = false;

if (bankAccount::balance

return balanceBelow; }

double checkingAccount::withdraw(double withdrawalAmt) { //check if enough balance if ((bankAccount::balance - withdrawalAmt)

void checkingAccount::writeCheck(string recipient, double checkAmount) { if ((balance - checkAmount)

checkingAccount.h

#include #include using namespace std;

class checkingAccount : public bankAccount { private: double interestRate; double minimumBalance; double serviceCharge; public: //checkingAccount(); checkingAccount(string acctNum, double startBal, double intRate, double minBalance, double srvCharge); //~checkingAccount(); double getInterestRate(); double getMinimumBalance(); double getServiceCharge(); double postInterest(); void print(); void setInterestRate(double intRate); void setMinimumBalance(double minBalance); void setServiceCharge(double srvCharge); bool verifyMinimumBalance(); double withdraw(double withdrawalAmt); void writeCheck(string recipient, double checkAmount); };

#endif

savingsAccount.cpp

#include "savingsAccount.h"

//savingsAccount::savingsAccount() //{ //}

savingsAccount::savingsAccount(string acctNum, double startBal, double intRate) : bankAccount(acctNum, startBal) { accountNumber = acctNum; //balance = startBal; //interestRate = intRate; }

//savingsAccount::~savingsAccount() //{ //}

double savingsAccount::getInterestRate() { return interestRate; }

double savingsAccount::postInterest() { double interest = 0; interest = bankAccount::balance * (interestRate / 100); bankAccount::balance += interest;

return interest; }

void savingsAccount::print() { cout

void savingsAccount::setInterestRate(double intRate) { interestRate = intRate; }

double savingsAccount::withdraw(double withdrawalAmt) { //verify there's enough money in account if ((bankAccount::balance - withdrawalAmt)

savingsAccount.h

#ifndef SAVINGSACCOUNT_H #define SAVINGSACCOUNT_H #include #include #include "bankAccount.h" using namespace std;

class savingsAccount : public bankAccount { private: double interestRate; public: //savingsAccount(); savingsAccount(string acctNum, double startBal, double intRate); //~savingsAccount(); double getInterestRate(); double postInterest(); void print(); void setInterestRate(double intRate); double withdraw(double withdrawalAmt); };

#endif

bankAccountTest.cpp

#include

#include

#include "savingsAccount.h"

#include "checkingAccount.h"

using namespace std;

int main()

{

bankAccount *accountsList[6];

accountsList[0] = new checkingAccount("Bill", 10200, 25000,100,0.012,10.00);

accountsList[1] = new checkingAccount("Bob", 10210, 10000,100,0.0099,15.00);

accountsList[2] = new savingsAccount("Susan", 90001, 20000,0.031);

accountsList[3] = new savingsAccount("Steve", 90002, 50000,0.041);

accountsList[4] = new checkingAccount("Sally", 10220, 4999,100,0.0079,20.00);

accountsList[5] = new savingsAccount("Frad", 90003, 2000,0.011);

cout

for (int i = 0; i

{

accountsList[i]->createMonthlyStatement();

accountsList[i]->print();

cout

}

cout

for (int i = 0; i

{

accountsList[i]->createMonthlyStatement();

accountsList[i]->print();

cout

}

for (int i = 0; i

{

accountsList[i]->withdraw(500);

}

cout

for (int i = 0; i

{

accountsList[i]->createMonthlyStatement();

accountsList[i]->print();

cout

}

return 0;

}

bankAccount polymorphism Create from scratch or modify week 2 program as follows bankAccount The bankAccount class will be abstract in this assignment and will use virtual and ure virtual functions Data accountNumber ame balance Methods getAccountNumber getBalance getName setName deposit withdraw (virtual) print (virtual) createMonthlyStatement (pure vi Constructor sets account number set account holder name sets account balance Note Print)- displays the account number and balance Derive class checkingAccount from base class bankAccount. The checkingAccount class should define and implement the following data and methods checkingAccount Data interestRate minimumBalance serviceCharge Methods getMinimumBalance setMinimumBalance getInterestRate setInterestRate getServiceCharge setServiceCharge postInterest writeCheck withdraw print createMonthlyStatement Constructor: sets account holder name sets account number sets account balance sets minimum balance set interest rate sets service charge amount sets amount of monthly fee NOTES postlnterest takes the interest amount based off of the total balance and adds it to the balance (balance + balanceinterestRate) writeCheck calls withdraw withdraw checks to make sure there is enough money in the account first and reports a warning if not. If there is enough money to make the withdraw, it then checks to see if the balance will go below the minimum amount after the withdraw. If so, it checks to see if the balance will go below zero after the withdraw and the service charge is applied. Should this occur an error is reported. If not, the balance is adjust to reflect the withdraw and the service charge applied createMonthlyStatement this posts the interest (calls postlnterest()) and deducts the monthly fee from the balance Print uses the base class print) and then also prints the interest rate Derive class savingsAccount from base class bankAccount. The savingsAccount class should define and implement the following data and methods savingsAccount Data interestRate Methods getInterestRate setInterestRate withdraw print createMonthlyStatement Constructor sets account holder name sets account number sets account balance set interest rate NOTES Withdraw checks to make sure there is enough money before altering the balance. If not, a warning message is printed and the balance remains unchanged Create monthly statement - this posts the interest to the account Print uses the base class print and then also prints the interest rarte Create a main program to test the class as follows. Use hard coded data (do not prompt the user for data, just make up values). Perform these steps in order define an array to hold 6 bankAccount classes. store 3 new checking accounts and 3 new savings accounts in the array Print a "January Header for all 6 accounts, create the monthly statement then print the account info print a February header for all 6 accounts, create the monthly statement then print the account info withdraw 500 for each account print a match header for all 6 accounts, create the monthly statement then print the account info Output can look similar to this anuary: Interest Checking ACCT#: Interest Checking ACCT#: Savings ACCT#: Savings ACCT#: Interest Checking ACCT#: Savings ACCT#: February: 10200 balance : S2 5290.00 10210 balance : S10089.00 Interest Rate-1.20% Interest Rate = 0.99% 90001 balance: S20620.00 Interest Rate 3.10% 90002 balance: S52050.00 Interest Rate 4.10% 10220 balance : S5028.49 Interest Rate = 0.79% 90003 balance: S2022.00 Interest Rate 1.10% Interest Checking ACCT#: Interest Checking ACCT#: Savings ACCT#: Savings ACCT#: Interest Checking ACCT#: Savings ACCT#: March: 10200 balance : S2 5583.48 102 10 balance : S101 78.88 Interest Rate = 1.20% Interest Rate = 0.99% 90001 balance: S21259.22 Interest Rate 3.10% 90002 balance: S54184.05 Interest Rate 4.10% 10220 balance : S5058.22 Interest Rate = 0.79% 90003 balance : S204424 Interest Rate-1.10% Interest Checking ACCT#: Interest Checking ACCT#: Savings ACCT#: Savings ACCT#: Interest Checking ACCT#: Savings ACCT#: 10200 balance : S25374.48 10210 balance : S9764.70 Interest Rate = 1.20% Interest Rate = 0.99% 90001 balance: S21402.76 Interest Rate-3.10% 90002 balance : S55885.10 Interest Rate 4.10% 10220 balance : S458423 Interest Rate = 0.79% 90003 balance: S1561.23 Interest Rate 1.10% Implementation Requirements You will create seven files for this assignment: bankAccount.h (base class definition) bankAccount.cpp (base class implementation) checkingAccount.h (checkingAccount definition) checkingAccount.cpp (checkingAccount implementation) savingsAccount.h (savingsAccount definition) savingsAccount.cpp (savingsAccount implementation) bankAccountTest.cpp (test file for your bankAccount class)

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

3. What should a contract of employment contain?

Answered: 1 week ago

Question

1. What does the term employment relationship mean?

Answered: 1 week ago