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

Create a new project that consists of the base class BankAccount. The BankAccoun

ID: 1810804 • Letter: C

Question

Create a new project that consists of the base class BankAccount.

The BankAccount class should contain, at minimum, the following members.

It should contain data members to store a bank customer's balance and account number. These should be of different and appropriate data types.

It should have function members that do the following:

The class CheckingAccount should contain, at a minimum, the following members.

It should contain a data member to keep track of the number of withdrawal transactions made on the account. Whenever a withdrawal is made, this number should be incremented.

Override the base class, withdraw-money function, and add the capability to deduct transaction fees from an account using the following guidelines.

3. Call all member functions for each account.

4.Each account operation should display the account number and the account balance.

Please answer all the lab questions in the text file that is to be turned into the Dropbox. You are not required to copy the question text into your document, but all answers should be listed with the question number they answer.



Explanation / Answer

#include <iostream>

#include <time.h>

using namespace std;

class BankAccount

{

public:

// constructors

BankAccount(){};

BankAccount(int);

// getters and setters

void setAccountNumber(int);

int getAccountNumber();

double getBalance();

void setBalance(double);

// account operations

void deposit(double);

bool withdraw(double);

protected:

int accountNumber; //account number

double balance; //balance

};

// member function definitions of BankAccount class

BankAccount::BankAccount(int num)

{

setAccountNumber(num);

balance = 0;

}

void BankAccount::setAccountNumber(int num)

{

accountNumber = num;

}

int BankAccount::getAccountNumber(){

return accountNumber;

}

double BankAccount::getBalance(){

return balance;

}

void BankAccount::setBalance(double bal){

balance = bal;

}

//deposits specified amount

void BankAccount::deposit(double amount)

{

balance = balance + amount;

}

//return true if withdrawl is successful

//otherwise returns false

bool BankAccount::withdraw(double amount)

{

if(balance < amount)

return false;

else

{

balance = balance - amount;

return true;

}

}

/* =======================================

* Checking Account inherits from BankAccount

* ======================================= */

class CheckingAccount :public BankAccount

{

public:

CheckingAccount();

CheckingAccount(int);

bool withdraw(double);

private:

int numOfWithdrawls; // number of withdrawl count

};

// member function definitions of CheckingAccount class

CheckingAccount::CheckingAccount():BankAccount()

{

numOfWithdrawls = 0;

}

CheckingAccount::CheckingAccount(int num):BankAccount(num)

{

numOfWithdrawls = 0;

}

// overridden withdrawl method

bool CheckingAccount::withdraw(double amount)

{

if(numOfWithdrawls > 3)

amount = amount + 50;

numOfWithdrawls++;

if( balance < amount)

return false;

else

balance = balance - amount;

return true;

}

/* =======================================

* Savings Account inherits from BankAccount

* ======================================= */

class SavingsAccount :public BankAccount

{

public:

SavingsAccount();

SavingsAccount(int);

void setAnnualInterest(double);

double getBalance();

double intEarnedSinceLastTrans();

int numOfDaysSinceLastTrans();

private:

// daily interest rate

double dailyInterestRate;

//interets earned since last transaction

double intEarnSinceLastTrans;

// number of days since last transaction occured

int numOfDays;

};

// member function definitions of SavingsAccount class

SavingsAccount::SavingsAccount():BankAccount()

{

numOfDays = rand()%8;

}

SavingsAccount::SavingsAccount(int num):BankAccount(num)

{

numOfDays = rand()%8;

}

void SavingsAccount::setAnnualInterest(double rate)

{

dailyInterestRate = rate/365;

}

int SavingsAccount::numOfDaysSinceLastTrans()

{

return numOfDays;

}

double SavingsAccount::intEarnedSinceLastTrans()

{

return numOfDays * dailyInterestRate;

}

double SavingsAccount::getBalance()

{

balance = balance + (numOfDays * dailyInterestRate);

numOfDays = rand()%8;

return balance;

}

//main function

int _tmain(int argc, _TCHAR* argv[])

{

srand(time(NULL));

//saving and checking acc objetcs

SavingsAccount sa(12345);

CheckingAccount ca(54321);

//sets initila balance

sa.setBalance(100);

ca.setBalance(100);

//sets annual interets rate

sa.setAnnualInterest(0.03);

//displaying account details

cout<<"Account Number: "<<sa.getAccountNumber()<<endl;

cout<<"Account Type: Savings"<<endl;

cout<<"Balance: $"<<sa.getBalance()<<endl;

cout<<"Number of days since last transcation: "<<sa.numOfDaysSinceLastTrans()<<endl;

cout<<"Interest earned since last transaction: $"<<sa.intEarnedSinceLastTrans()<<endl;

cout<<" Account Number: "<<ca.getAccountNumber()<<endl;

cout<<"Account Type: Checking"<<endl;

cout<<"Balance: $"<<ca.getBalance()<<endl;

return 0;

}

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