Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is the given bank account class. Part 1. The instructions are Write a test

ID: 3880650 • Letter: T

Question

This is the given bank account class.

Part 1. The instructions are Write a test program to test only this

bankAccount class

// bankAccount.h

#pragma once

#include <iostream>

#ifndef BANK_ACCOUNT

#define BANK_ACCOUNT

class bankAccount

{

public:

void setAccountNumber(int acct);

int getAccountNumber() const;

double getBalance() const;

void withdraw(double amount);

void deposit(double ammount);

void print() const;

bankAccount(int acctNumber = -1, double bal = 0);

protected:

int accountNumber;

double balance;

};

#endif

For parts 2 and 3 I must write a class for both a checking account and a savings account via inheritance of the bankAccount class

Part 2

: Create the checkingAccount class via Inheritance Using Inheritance, create class checkingAccount

by deriving from the class bankAccount used in Part 1 A person with a checkingAccount has the following:

a. An account number

b. A balance amount

c. A minimum balance amount

d. Interest rate

e. Surcharge paid if balance falls below the minimum balance amount.

Note that part (a) and (b) are obtained via Inheritance from the parent class.

Hence only part (c) to (e) will be items must be data members in the

checkingAccount class. The following functions should be defined in this class:

a. Set interest rate

b. Retrieve interest rate

c. Set minimum balance

d. Retrieve minimum balance

e. Set service charge

f. Retrieve service charge

g. Post interest, that is, update the balance with the interest amount which

is based on the interest rate.

h. Override the withdraw() function to ensure that enough amount in the

balance to be withdrawn. Also check if after withdraw resulting in balance

less than minimum balance, hence apply the surcharge.

i. Verify if balance is less than minimum balance (return a Boolean value)

j. Override the print() function to show that it is a Checking account #.

Same information printed but only modify the description.

k. A constructor for checkingAccount to accept values for accountNumber,

balance, minimum balance, interest rate and service charge. This

constructor should call the bankAccount constructor with accountNumber and

balance.

Write a test program to test only this checkingAccount class.

Explanation / Answer

#ifndef BANKACCOUNT_H_ #define BANKACCOUNT_H_ #include class BankAccount { protected: double balance; public: BankAccount(double startingBalance) { balance = startingBalance; } virtual ~BankAccount() {} virtual void deposit(double amt) { balance += amt; } virtual void withdraw(double amt) { balance -= amt; } virtual void printMonthlyStatement() = 0; // pure virtual function }; #endif /* BANKACCOUNT_H_ */ #ifndef CHECKING_H_ #define CHECKING_H_ #include "BankAccount.h" class Checking : public BankAccount{ private: double charges; int maxW; // maximum of free withdrawals per month int withdrawals; // number of withdrawals this month void applyCharges(); // calculates the monthly charges and subtracts it from the balance public: // default: a charge of $0.1 applies after 5 withdrawals per month Checking(double amt, int maxW = 5, double charges = 0.1); virtual ~Checking(); void deposit(double amt); // calls deposit from base class void withdraw(double amt); // checks if enough funds before calling withdraw from base class void printMonthlyStatement(); // prints monthly statement after calculating the charges to update the balance }; #endif /* CHECKING_H_ */ #ifndef SAVINGS_H_ #define SAVINGS_H_ #include "BankAccount.h" class Savings : public BankAccount { private: double interestRate; void applyInterest(); // calculates the monthly interest and adds it to the balance public: Savings(double amt, double intRate = 0.01); virtual ~Savings(); void deposit(double amt); // calls deposit from base class void withdraw(double amt); // checks if enough funds before calling withdraw from base class void printMonthlyStatement(); // prints monthly statement after calculating the interest to update the balance }; #endif /* SAVINGS_H_ */ #include "Checking.h" using namespace std; Checking::Checking(double amt, int maxW, double charges): BankAccount(amt) { this->maxW = maxW; this->charges = charges; withdrawals = 0; } Checking:: ~Checking() { } void Checking:: deposit(double amt)// calls deposit from base class { BankAccount::deposit(amt); } void Checking:: withdraw(double amt) // checks if enough funds before calling withdraw from base class { if(amt
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote