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

C++ INHERITANCE HELP!!!! 1) Define the class bankAccount to store a bank custome

ID: 3809545 • Letter: C

Question

C++ INHERITANCE HELP!!!!

1) Define the class bankAccount to store a bank customer’s account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should provide the following operations:

Set the account number

Return the account number

Return the balance

Deposit money into Account

Withdraw money from Account

Print account information (Bank Name, Account number, and account balance)

Add the appropriate constructors

2)Derive the class checkingAccount from the class bankAccount. A customer receives interest, maintains a minimum balance, and pays service charges if the balance falls below the minimum balance. Add member variables to store this additional information.

In addition to the operations inherited from the base class, this class should provide the following operations:

Set interest rate

Return interest rate

Set minimum balance

Return minimum balance

Set service charges

Return service charges

Verify if the balance is less than the minimum balance

Withdraw money from checkingAccount (override the method of the base class)

Add the appropriate constructors

What to submit:

The bankAccount.h file

The bankAccount.cpp file

The checkingAccount.h file

The checkingAccount.cpp file

The test.cpp file

Explanation / Answer

bankAccount.h


#include <iostream>
#include <iomanip>
using namespace std;


class BankAccount{
public:

   BankAccount();
   BankAccount(double balance);
   int get_actNumber();
   void deposit(double amount);
   void withdrawl(double amount);
   double get_balance();
   void printInfo();


protected:
   double _balance;
   static int _number;
};
BankAccount::BankAccount()
{
   _balance = 0.0;
  
}

BankAccount::BankAccount(double balance)
{
   _balance = balance;
  
  
}

int BankAccount::get_actNumber()
{
   return _number = _number + 100;
}
void BankAccount::deposit(double amount)
{
   _balance = _balance + amount;
}
void BankAccount::withdrawl(double amount)
{
   _balance = _balance - amount;
}
double BankAccount::get_balance()
{
   return _balance;
}
int BankAccount::_number = 1000;

checkingAccount.h

#include <iostream>
#include <iomanip>
#include "bankAccount.h"

#ifndef checkingAccount_H
#define checkingAccount_H
using namespace std;

class checkingAccount : public bankAccount
{
public:
   checkingAccount(double balance);

  
   //checkingAccount(double balance);
   void set_interestRate(double rate);
   double get_interestRate();
   void set_minBalance(double minBal);
   double get_minBalance();
   void set_fee(double fee);
   double get_fee();
   void postInterest();
   bool checkMin();
   void withdrawl(double amount);
   void writeCheck(double amount);
   void printInfo();
   //void checkingAccount::printInfo()


protected:
   double _rate, _minBalance, _fee;
  


};
#endif

checkingAccount::checkingAccount(double balance)//Since the tester that was provided doesnt set the rate, min balance or fee I just set it here
   : bankAccount(balance)
{
   _number = get_actNumber();
   _fee = 15;
   _minBalance = 200;
   _rate = 0.04;
}

void checkingAccount::set_interestRate(double rate)
{
   _rate = rate;
}
double checkingAccount::get_interestRate()
{
   return _rate;
}
void checkingAccount::set_minBalance(double minBal)
{
   _minBalance = minBal;
}
double checkingAccount::get_minBalance()
{
   return _minBalance;
}
bool checkingAccount::checkMin()
{
   if (_balance >= _minBalance)
   {
       return true;
   }
   else
       return false;
}
void checkingAccount::set_fee(double fee)
{
   _fee = fee;
}
double checkingAccount::get_fee()
{
   return _fee;
}
void checkingAccount::postInterest()
{
   _balance += (_balance * _rate);
}
void checkingAccount::withdrawl(double amount)
{
   if (_balance < amount)
   {
       cout << "insufficient funds. Withdrawl rejected, does not affect balance." << endl;
   }
   else//I assume the bank will allow a withdrawl as long as the balance is greater than the amount even if the fee drops the account into the negative
   {
       if (_balance - amount >= _minBalance)
       {
           _balance = _balance - amount;
       }
       else
       {
           _balance -= (amount + _fee);
          
       }

   }
}
void checkingAccount::writeCheck(double amount)
{
   withdrawl(amount);
}
void checkingAccount::printInfo()
{
   cout << "Interest Checking ACCT#:" << get_actNumber() << " Balance: $" << setprecision(2) << fixed << get_balance() << endl;
}

test.cpp

#include <iostream>
#include <iomanip>
#include "SavingsAccount.h"
#include "CheckingAccount.h"

using namespace std;

int main()
{


CheckingAccount jackAccount(1000);
CheckingAccount lisaAccount(450);
SavingsAccount samirAccount(9300);
SavingsAccount ritaAccount(32);

jackAccount.deposit(1000);
lisaAccount.deposit(2300);
samirAccount.deposit(800);
ritaAccount.deposit(500);

jackAccount.postInterest();
lisaAccount.postInterest();
samirAccount.postInterest();
ritaAccount.postInterest();

cout << "***********************************" << endl;
jackAccount.print();
lisaAccount.print();
samirAccount.print();
ritaAccount.print();
cout << "***********************************" << endl << endl;

jackAccount.writeCheck(250);
lisaAccount.writeCheck(350);
samirAccount.withdraw(120);
ritaAccount.withdraw(290);

cout << "********After withdrawals ***************" << endl;
jackAccount.print();
lisaAccount.print();
samirAccount.print();
ritaAccount.print();
cout << "***********************************" << endl << endl;

   system("pause");
return 0;
}