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

Example of how its suppose to look Banks offer various types of accounts, such a

ID: 3826920 • Letter: E

Question

Example of how its suppose to look

Banks offer various types of accounts, such as savings, checking, certificate of deposits, and money market, to attract customers as well as meet their specific needs. Two of the most commonly used accounts are savings and checking. Each of these accounts has various options. For example, you may have a savings account that requires no minimum balance but has a lower interest rate. Similarly, you may have a checking account that limits the number of checks you may write. Another type of account that is used to save money for the long term is certificate of deposit (CD) In this programming exercise, you use abstract classes and pure virtual functions to design classes to manipulate various types of accounts. For simplicity, assume that the bank offers three types of accounts: savings, checking, and certificate of deposit, as described next. Savings accounts: Suppose that the bank offers two types of savings accounts: one that has no minimum balance and a lower interest rate and another that requires a minimum balance and has a higher interest rate Checking accounts: Suppose that the bank offers three types of checking accounts: one with a monthly service charge limited check writing, no minimum balance, and no interest, another with no monthly service charge, a minimum balance requirement, unlimited check writing and lower interest, and a third with no monthly service charge, a higher minimum requirement, a higher interest rate, and unlimited check writing Certificate of deposit (CD): In an account of this type, money is left for some time, and these accounts draw higher interest rates than savings or checking accounts. Suppose that you purchase a CD for six months. Then we say that the CD will mature in six months. The penalty for early withdrawal is stiff

Explanation / Answer

main.cpp


#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include "bankAccount.h"
#include "savingsAccount.h"
#include "highInterestSavings.h"
#include "serviceChargeChecking.h"
#include "noServiceChargeChecking.h"
#include "highInterestChecking.h"
#include "certificateOfDeposit.h"

using namespace std;

int main()
{
   bankAccount *accountsList[6];

   accountsList[0] = new savingsAccount("Bill", 10200, 2500);
   accountsList[1] = new highInterestSavings("Susan", 10210, 2000);
   accountsList[2] = new noServiceChargeChecking("John", 20100, 3500);
   accountsList[3] = new serviceChargeChecking("Ravi", 30100, 1800);
   accountsList[4] = new highInterestChecking("Sheila", 20200, 6000);
   accountsList[5] = new certificateOfDeposit ("Hamid", 51001, 18000, 0.075, 18);
  
   cout << "January:" << endl
       << "--------------" << endl;
   for (int i=0; i < 6; i++)
   {
       accountsList[i]->createMonthlyStatement();
       accountsList[i]->print();

       cout << endl;
   }

   cout << endl << "February:" << endl
       << "--------------" << endl;
   for (int i=0; i < 6; i++)
   {
       accountsList[i]->createMonthlyStatement();
       accountsList[i]->print();

       cout << endl;
   }

   for (int i=0; i < 6; i++)
       accountsList[i]->withdraw(500);

   cout << endl << "March:" << endl
       << "--------------" << endl;
   for (int i=0; i < 6; i++)
   {
       accountsList[i]->createMonthlyStatement();
       accountsList[i]->print();

       cout << endl;
   }

   cout << endl << "Program by: Xavier Fox" << endl << endl;

   return 0;
}


bankAccount.h


#ifndef bankAccount_H
#define bankAccount_H

#include <string>

using namespace std;

class bankAccount
{
protected:
   int accountNumber;
   string name;
   double balance;

public:
   bankAccount(string n="", int acctNum=0, double bal=0.0);
   int getAccountNumber();
   double getBalance();
   string getName();
   void setName(string n);
   virtual void withdraw(double amount);
   void deposit(double amount);
   virtual void createMonthlyStatement() = 0;
   virtual void print();
};

#endif

bankAccount.cpp


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

using namespace std;

// constructor
bankAccount::bankAccount(string n, int acctNum, double bal)
{
   name = n;
   accountNumber = acctNum;
   balance = bal;
}


// gets the account number
int bankAccount::getAccountNumber()
{
   return accountNumber;
}

// gets the balance
double bankAccount::getBalance()
{
   return balance;
}

// gets the name
string bankAccount::getName()
{
   return name;
}


// sets the name
void bankAccount::setName(string n)
{
   name = n;
}

// takes away the withdraw amount
void bankAccount::withdraw(double amount)
{
   balance -= amount;
}

// adds the deposit amount
void bankAccount::deposit(double amount)
{
   balance += amount;
}

// prints the name, account number and balance
void bankAccount::print()
{
   cout << fixed << showpoint << setprecision(2);
   cout << name << " " << accountNumber << " balance: $"
       << setw(9) << balance;
}

certificateOfDeposit.cpp


#include "stdafx.h"
#include "certificateOfDeposit.h"
#include <string>
#include <iostream>
#include <iomanip>

using namespace std;

const double certificateOfDeposit::INTEREST_RATE = 0.05;
const int certificateOfDeposit::NUMBER_OF_MATURITY_MONTHS = 6;

// constructor
certificateOfDeposit::certificateOfDeposit(string n, int acctNum, double bal)
                   :bankAccount(n, acctNum, bal)
{
   interestRate = INTEREST_RATE;
   maturityMonth = NUMBER_OF_MATURITY_MONTHS;
   cdMonth = 0;
}

// constructor
certificateOfDeposit::certificateOfDeposit(string n, int acctNum, double bal,
                                           double intRate, int maturityMon)
                   :bankAccount(n, acctNum, bal)
{
   interestRate = intRate;
   maturityMonth = maturityMon;
   cdMonth = 0;
}

// gets the interest rate
double certificateOfDeposit::getInterestRate()
{
   return interestRate;
}

// sets the interest rate
void certificateOfDeposit::setInterestRate(double intRate)
{
   interestRate = intRate;
}

// gets the current CD month
double certificateOfDeposit::getCurrentCDMonth()
{
   return cdMonth;
}

// sets the current CD month
void certificateOfDeposit::setCurrentCDMonth(int month)
{
   cdMonth = month;
}

// gets the maturity month
double certificateOfDeposit::getMaturityMonth()
{
   return maturityMonth;
}

// sets the maturity month
void certificateOfDeposit::setMaturityMonth(int month)
{
   maturityMonth = month;
}

// accounts for the post interest
void certificateOfDeposit::postInterest()
{
   balance += (balance * interestRate);
}

void certificateOfDeposit::withdraw(double amount)
{
   // no withdrawl until maturity
}

// accounts for the withdrawl
void certificateOfDeposit::withdraw()
{
   if (cdMonth > maturityMonth)
       balance = 0;
   else
       cout << "CD has not been matured. No withdrawal." << endl;
}

// creates the monthly statement
void certificateOfDeposit::createMonthlyStatement()
{
   postInterest();
}

// prints the certificate of deposit account
void certificateOfDeposit::print()
{
   cout << fixed << showpoint << setprecision(2);
   cout << left << setw(29) << "Certificate Of Deposit:" << setw(12) << getName()
       << "ACCT# " << setw(8) << getAccountNumber() << setw(11) << "Balance: $"
       << right << setw(9) << getBalance();
}

certificateOfDeposit.h


#ifndef certificateOfDeposit_H
#define certificateOfDeposit_H

#include "bankAccount.h"
#include <string>

using namespace std;

class certificateOfDeposit:public bankAccount
{
public:
   certificateOfDeposit(string n, int acctNum, double bal);
   certificateOfDeposit(string n, int acctNum, double bal, double intRate,
                       int maturityMon);
   double getInterestRate();
   void setInterestRate(double intRate);
   double getCurrentCDMonth();
   void setCurrentCDMonth(int month);
   double getMaturityMonth();
   void setMaturityMonth(int month);
   void postInterest();
   void withdraw(double amount);
   void withdraw();
   void createMonthlyStatement();
   void print();

private:
   static const double INTEREST_RATE;
   static const int NUMBER_OF_MATURITY_MONTHS;

   double interestRate;
   int maturityMonth;

   int cdMonth;
};

#endif

checkingAccout.h

#ifndef checkingAccount_H
#define checkingAccount_H

#include <string>
#include "bankAccount.h"

using namespace std;

class checkingAccount: public bankAccount
{
public:
   checkingAccount(string n, int acctNum, double bal);
   virtual void writeCheck(double amount) = 0;
};

#endif

checkingAccount.cpp


#include "stdafx.h"
#include "checkingAccount.h"
#include <string>
#include <iostream>

using namespace std;

// constructor
checkingAccount::checkingAccount(string n, int acctNum, double bal)
               :bankAccount(n, acctNum, bal)
{
}

highInterestChecking.h


#ifndef highInterestChecking_H
#define highInterestChecking_H

#include "noServiceChargeChecking.h"
#include <string>

using namespace std;

class highInterestChecking: public noServiceChargeChecking
{
public:
   highInterestChecking(string n, int acctNum, double bal);
   highInterestChecking(string n, int acctNum, double bal, double minBal,
                       double intRate);
   double getInterestRate();
   void setInterestRate(double intRate);
   void postInterestRate();
   virtual void createMonthlyStatement();
   virtual void print();

private:
   static const double INTEREST_RATE;
   static const double MIN_BAL;
};

#endif


highInterestChecking.cpp


#include "stdafx.h"
#include "highInterestChecking.h"
#include <string>
#include <iostream>
#include <iomanip>

using namespace std;

const double highInterestChecking::INTEREST_RATE = 0.05;
const double highInterestChecking::MIN_BAL = 5000;

// constructor
highInterestChecking::highInterestChecking(string n, int acctNum, double bal)
                   :noServiceChargeChecking(n, acctNum, bal)
{
   minimumBalance = MIN_BAL;
   interestRate = INTEREST_RATE;
}

// constructor
highInterestChecking::highInterestChecking(string n, int acctNum, double bal,
                                           double minBal, double intRate)
                   :noServiceChargeChecking(n, acctNum, bal, minBal, intRate)
{
}

// gets the interest rate
double highInterestChecking::getInterestRate()
{
   return interestRate;
}

// sets the interest rate
void highInterestChecking::setInterestRate(double intRate)
{
   interestRate = intRate;
}

// accounts for the post interest rate
void highInterestChecking::postInterestRate()
{
   balance += (balance * interestRate);
}

// creates the monthly statement
void highInterestChecking::createMonthlyStatement()
{
   postInterestRate();
}

// prints the high interest checking
void highInterestChecking::print()
{
   cout << fixed << showpoint << setprecision(2);
   cout << left << setw(29) << "High Interest Checking:" << setw(12) << getName()
       << "ACCT# " << setw(8) << getAccountNumber() << setw(11) << "Balance: $"
       << right << setw(9) << getBalance();
}

highInterestSavings.h


#ifndef highInterestSavings_H
#define highInterestSavings_H

#include <string>
#include "savingsAccount.h"

using namespace std;

class highInterestSavings: public savingsAccount
{
private:
   static const double MINIMUM_BALANCE;
   static const double INTEREST_RATE;

protected:
   double minimumBalance;

public:
   highInterestSavings(string n, int acctNum, double bal);
   highInterestSavings(string n, int acctNum, double bal, double intRate,
                       double minBalance);
   double getMinimumBalance();
   bool verifyMinimumBalance(double amount);
   virtual void withdraw(double amount);
   virtual void print();
};

#endif

highInteresSavings.cpp


#include "stdafx.h"
#include "highInterestSavings.h"
#include <string>
#include <iostream>
#include <iomanip>

using namespace std;

const double highInterestSavings::MINIMUM_BALANCE = 2500.00;
const double highInterestSavings::INTEREST_RATE = 0.05;

// constructor
highInterestSavings::highInterestSavings(string n, int acctNum, double bal)
                   : savingsAccount(n, acctNum, bal, INTEREST_RATE)
{
   minimumBalance = MINIMUM_BALANCE;
}

// constructor
highInterestSavings::highInterestSavings(string n, int acctNum, double bal,
                                       double intRate, double minBal)
                   :savingsAccount(n, acctNum, bal, intRate)
{
   minimumBalance = minBal;
}

// gets the minimum balance
double highInterestSavings::getMinimumBalance()
{
   return minimumBalance;
}

// verifies the minimum balance
bool highInterestSavings::verifyMinimumBalance(double amount)
{
   return (balance - amount >= minimumBalance);
}

// accounts for a withdraw
void highInterestSavings::withdraw(double amount)
{
   if (verifyMinimumBalance(amount))
       balance -= amount;
}

// prints the high interest savings account
void highInterestSavings::print()
{
   cout << fixed << showpoint << setprecision(2);
   cout << left << setw(29) << "High Interest Savings:" << setw(12) << getName()
       << "ACCT# " << setw(8) << getAccountNumber() << setw(11) << "Balance: $"
       << right << setw(9) << getBalance();
}


noServiceChargeChecking.cpp


#include "stdafx.h"
#include "noServiceChargeChecking.h"
#include <string>
#include <iostream>
#include <iomanip>

using namespace std;

const double noServiceChargeChecking:: MIN_BALANCE = 1000.00;
const double noServiceChargeChecking:: INTEREST_RATE = 0.02;

// constructor
noServiceChargeChecking::noServiceChargeChecking(string n, int acctNum, double bal)
                       :checkingAccount(n, acctNum, bal)
{
   minimumBalance = MIN_BALANCE;
   interestRate = INTEREST_RATE;
}

// constructor
noServiceChargeChecking::noServiceChargeChecking(string n, int acctNum, double bal,
                                               double minBalance, double intRate)
                       :checkingAccount(n, acctNum, bal)
{
   minimumBalance = minBalance;
   interestRate = intRate;
}

// gets the minimum balance
double noServiceChargeChecking::getMinimumBalance()
{
   return minimumBalance;
}

// sets the minimum balance
void noServiceChargeChecking::setMinimumBalance(double minBalance)
{
   minimumBalance = minBalance;
}

// verifies the minimum balance
bool noServiceChargeChecking::verifyMinimumBalance(double amount)
{
   return (balance - amount >= minimumBalance);
}

// takes away the amount from balance from the check
void noServiceChargeChecking::writeCheck(double amount)
{
   if (verifyMinimumBalance(amount))
       balance -= amount;
}

// accounts for a withdraw
void noServiceChargeChecking::withdraw(double amount)
{
   if (verifyMinimumBalance(amount))
       balance -= amount;
}

// creates a monthly statement
void noServiceChargeChecking::createMonthlyStatement()
{
}

// prints the no service charge checking
void noServiceChargeChecking::print()
{
   cout << fixed << showpoint << setprecision(2);
   cout << left << setw(29) << "No Service Charge Checking:" << setw(12) << getName()
       << "ACCT# " << setw(8) << getAccountNumber() << setw(11) << "Balance: $"
       << right << setw(9) << getBalance();
}


noServiceChargeChecking.h


#ifndef noServiceChargeChecking_H
#define noServiceChargeChecking_H

#include <string>
#include "checkingAccount.h"

using namespace std;

class noServiceChargeChecking: public checkingAccount
{
public:
   noServiceChargeChecking(string n, int acctNum, double bal);
   noServiceChargeChecking(string n, int acctNum, double bal, double minBalance,
                           double intRate);
   double getMinimumBalance();
   void setMinimumBalance(double minBalance);
   bool verifyMinimumBalance(double amount);
   void writeCheck(double amount);
   void withdraw(double amount);
   virtual void createMonthlyStatement();
   virtual void print();

protected:
   double minimumBalance;
   double interestRate;

private:
   static const double MIN_BALANCE;
   static const double INTEREST_RATE;
};

#endif

savingsAccount.h


#ifndef savingsAccount_H
#define savingsAccount_H

#include <string>
#include "bankAccount.h"

using namespace std;

class savingsAccount: public bankAccount
{
private:
   static const double INTEREST_RATE;
  
protected:
   double interestRate;

public:
   savingsAccount(string n, int acctNum, double bal);
   savingsAccount(string n, int acctNum, double bal, double intRate);
   double getInterestRate();
   void setInterestRate(double rate);
   void postInterest();
   virtual void createMonthlyStatement();
   virtual void print();
};

#endif

savingsAccount.cpp


#include "stdafx.h"
#include "savingsAccount.h"
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

const double savingsAccount::INTEREST_RATE=0.03;

// constructor
savingsAccount::savingsAccount(string n, int acctNum, double bal)
               :bankAccount(n, acctNum, bal)
{
   interestRate = INTEREST_RATE;
}

// constructor
savingsAccount::savingsAccount(string n, int acctNum, double bal, double intRate)
               :bankAccount(n, acctNum, bal)
{
   setInterestRate(intRate);
}

// gets the interest rate
double savingsAccount::getInterestRate()
{
   return interestRate;
}

// sets the interest rate
void savingsAccount::setInterestRate(double rate)
{
   interestRate = rate;
}

// adding the interest to the balance
void savingsAccount::postInterest()
{
   balance += balance * interestRate;
}

// creates the monthly statement
void savingsAccount::createMonthlyStatement()
{
   postInterest();
}

// prints the savings account
void savingsAccount::print()
{
   cout << fixed << showpoint << setprecision(2);
   cout << left << setw(29) << "Savings account:" << setw(12) << getName()
       << "ACCT# " << setw(8) << getAccountNumber() << setw(11) << "Balance: $"
       << right << setw(9) << getBalance();
}

serviceChargeChecking.h


#ifndef serviceChargeChecking_H
#define serviceChargeChecking_H

#include <string>
#include "checkingAccount.h"

using namespace std;

class serviceChargeChecking: public checkingAccount
{
public:
   serviceChargeChecking(string n, int acctNum, double bal);
   serviceChargeChecking(string n, int acctNum, double bal, double servChargeAmount,
                          double servChargeCheck);
   double getServiceChargeAmount();
   void setServiceCharge(double amount);
   double getServiceChargeCheck();
   void setServiceChargeCheck(double amount);
   int getNumberOfChecksWritten();
   void setNumberOfChecksWritten(int num);
   void postServiceCharge();
   void writeCheck(double amount);
   virtual void createMonthlyStatement();
   virtual void print();
  
protected:
   double serviceChargeAmount;
   double serviceChargeCheck;
   int numberOfChecksWritten;

private:
   static const double ACCOUNT_SERVICE_CHARGE;
   static const int MAXIMUM_NUM_OF_CHECKS;
   static const double SERVICE_CHARGE_EXCESS_NUM_OF_CHECKS;
};

#endif

servChargeCheckig.cpp


#include "stdafx.h"
#include "serviceChargeChecking.h"
#include <string>
#include <iostream>
#include <iomanip>

using namespace std;

const double serviceChargeChecking:: ACCOUNT_SERVICE_CHARGE = 10.00;
const int serviceChargeChecking:: MAXIMUM_NUM_OF_CHECKS = 5;
const double serviceChargeChecking:: SERVICE_CHARGE_EXCESS_NUM_OF_CHECKS = 5.00;

// constructor
serviceChargeChecking::serviceChargeChecking(string n, int acctNum, double bal)
                      :checkingAccount(n, acctNum, bal)
{
   serviceChargeAmount = ACCOUNT_SERVICE_CHARGE;
   numberOfChecksWritten = 0;
   serviceChargeCheck = 0.0;
}

// constructor
serviceChargeChecking::serviceChargeChecking(string n, int acctNum, double bal,
                                           double servChargeAmount,
                                           double servChargeCheck)
                      :checkingAccount(n, acctNum, bal)
{
   serviceChargeAmount = servChargeAmount;
   numberOfChecksWritten = 0;
   serviceChargeCheck = servChargeCheck;
}

// gets the service charge amount
double serviceChargeChecking::getServiceChargeAmount()
{
   return serviceChargeAmount;
}

// sets the service charge amount
void serviceChargeChecking::setServiceCharge(double amount)
{
   serviceChargeAmount = amount;
}

// gets the service charge check
double serviceChargeChecking::getServiceChargeCheck()
{
   return serviceChargeCheck;
}

// sets the service charge check
void serviceChargeChecking::setServiceChargeCheck(double amount)
{
   serviceChargeCheck = amount;
}

// gets the number of checks written
int serviceChargeChecking::getNumberOfChecksWritten()
{
   return numberOfChecksWritten;
}

// sets the number of checks written
void serviceChargeChecking::setNumberOfChecksWritten(int num)
{
   numberOfChecksWritten = num;
}

// accounts for the post service charge
void serviceChargeChecking::postServiceCharge()
{
   balance -= serviceChargeAmount;
}

// takes the amount of checks written away from the blance
void serviceChargeChecking::writeCheck(double amount)
{
   if (numberOfChecksWritten < MAXIMUM_NUM_OF_CHECKS)
       balance -= amount;
   else
       balance = balance - amount - serviceChargeCheck;

   numberOfChecksWritten++;
}

// creates the monthly statement
void serviceChargeChecking::createMonthlyStatement()
{
   postServiceCharge();
}

// prints the service charge checking
void serviceChargeChecking::print()
{
   cout << fixed << showpoint << setprecision(2);
   cout << left << setw(29) << "Service Charge Checking:" << setw(12) << getName()
       << "ACCT# " << setw(8) << getAccountNumber() << setw(11) << "Balance: $"
       << right << setw(9) << getBalance();
}

Dr Jack
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote