I was told the issue is in the BankAccounth where the guards

I was told the issue is in the BankAccount.h where the guards need to be moved around, but can\'t figure it out. Please help.

//tester.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;
}

//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;

//SavingsAccount.h

#include <iostream>
#include <iomanip>
#include \"BankAccount.h\"


#ifndef SAVINGACCOUNT_H
#define SAVINGACCOUNT_H

using namespace std;

class SavingAccount : public BankAccount
{
public:
   SavingAccount(double balance);
   void set_interestRate(double rate);
   double get_interestRate();
   void postInterest();
   void withdrawl(double amount);
   void printInfo();
protected:
   double _rate;

};
#endif
SavingAccount::SavingAccount(double balance)//Since the tester that was provided doesnt set the rate, min balance or fee I just set it here
   : BankAccount(balance)
{
   _rate = .06;
}
void SavingAccount::set_interestRate(double rate)
{
   _rate = rate;
}
double SavingAccount::get_interestRate()
{
   return _rate;
}
void SavingAccount::postInterest()
{
   _balance += (_balance * _rate);
}
void SavingAccount::withdrawl(double amount)
{
   if (_balance >= amount)
   {
       _balance = _balance - amount;
   }
   else
   {
       cout << \"Insufficient funds. Withdrawl transaction rejected, balance remains the same\" << endl;
   }
}
void SavingAccount::printInfo()
{
   cout << \"Interest Saving ACCT#:\" << get_actNumber() << \" Balance: $\" << setprecision(2) << fixed << get_balance() << endl;

}

//CheckingAccount.h

#include <iostream>
#include <iomanip>
#include \"BankAccount.h\"

// using namespace std; // *** don\'t have this in a header file


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;
}

Output should look like this?

***********************************

Interest Checking ACCT#:        1100    Balance: $2080.00

Interest Checking ACCT#:        1200    Balance: $2860.00

Savings ACCT#:                  1300    Balance: $10706.00

Savings ACCT#:                  1400    Balance: $563.92

***********************************

********After withdrawals ***************

Interest Checking ACCT#:        1100    Balance: $1830.00

Interest Checking ACCT#:        1200    Balance: $2510.00

Savings ACCT#:                  1300    Balance: $10586.00

Savings ACCT#:                  1400    Balance: $273.92

***********************************

Press any key to continue . . .

C Documents and settings Donaldwy Docume Ex14DebugwCh12 Ex14,exo LDx nterest checking ACCIH 1888 Balance 2088.00 nterest Checking ACCT Balance 2860.0B Savings AccTH 1002 Balance 10786.80 avings ACCT 1003 Balance: 563.92 fter withdrawa Balance: $1830.00 nterest Checking ACCI! 1000 nterest checking ACCIB 1881 Balance avings AccTH 1882 Balance Savings AccTll 1003 Balance: $273.92 Press any key to continue

Solution

#include <io stream>
#include <io manip>
using namespace std;
class bank Account
{public:
    bank Account(int,double);   
    void set AccNum(int);
    int get AccNum();
    double get Balance();
    void withdrawl(double);
    void deposit(double);
    void print();
protected:
    int accNum;
    double balance;
};
class savings Account: public bank Account
{public:
    savings Account(int,double);
    void set Rate(double);  
    double get Rate();
    void withdraw(double);
    void post Interest();
    void savings Account::print();
protected:
    double rate;
};
class checking Account: public bank Account
{
public:
    checking Account(int accNum,double bal);  
    double get MinBal();
    double get Rate();
    double get Fee();
    void set MinBal(double);   
    void set Rate(double);   
    void set Fee(double);
    void post Interest();
    bool check MinBal(double);
    void checking Account::write Check(double);
    void withdraw(double);
    void print();
protected:
    double rate,minBal,fee;
};
bank Account::bank Account(int n,double b)
{accNum=n;
balance=b;
}
void bank Account::set AccNum(int a)
{accNum=a;
}
int bank Account::get AccNum()
{return accNum;
}
double bank Account::get Balance()
{return balance;
}
void bank Account::withdraw(double a)
{balance-=a;
}
void bank Account::deposit(double a)
{balance+=a;
}
void bank Account::print()
{cout<<acc Num<<\"Balance: $\"<<set precision(2)<<fixed<<balance<<endl;
}
checking Account::checking Account(int n,double b):bank Account(n,b)
{setRate(.04);
setMinBal(500);
setFee(20);
}
double checking Account::get MinBal()
{return minBal;
}
double checking Account::get Rate()
{return rate;
}
double checking Account::getFee()
{return fee;
}
void checking Account::set MinBal(double m)
{minBal=m;
}
void checking Account::setRate(double r)
{rate=r;
}
void checking Account::set Fee(double f)
{fee=f;
}
void checking Account::postInterest()
{balance+=(balance*rate);
}
bool checking Account::check MinBal(double a)
{if(balance-a>=minBal)
       return true;
else
       return false;
}
void checking Account::write Check(double a)
{withdraw(a);
}
void checking Account::withdraw(double a)
{if(balance-a<0)
     count<<\"insufficient funds for $\"<<a<<\" withdrawal\ \";
else if(balance-a<minBal)
     if(balance-a-fee<minBal)
        count<<\"insufficient funds for withdrawal + fees, since balance will be below minimum\ \";
     else
        {count<<\"balance below minimum. $\"<<fee<<\" fee charged\ \";
         balance-=(a+fee);
        }
else
    balance-=a;
}
void checking Account::print()
{count<<\"Interest Checking ACCT#:\\t\"<<get AccNum()
     <<\"\\tBalance: $\"<<set precision(2)<<fixed<<get Balance()<<endl;
}
savings Account::savings Account(int n,double b):bank Account(n,b)
{setRate(.06);
}
double savings Account::getRate()
{return rate;
}
void savings Account::set Rate(double r)
{rate=r;
}
void savings Account::withdraw(double a)
{if(balance-a<0)
   count<<\"insufficient funds for $\"<<set precision(2)<<fixed<<\" withdrawal\ \";
else
balance-=a;
}
void savings Account::post Interest()
{balance+=(balance*rate);
}
void savings Account::print()
{count<<\"Savings ACCT#:\\t\\t\\t\"<<get AccNum()
      <<\"\\tBalance: $\"<<set precision(2)<<fixed<<get Balance()<<endl;
}
int main()

{    

int account Number = 1000;

checking Account jack Account(account Number++,1000);  

checking Account lisa Account(account Number++, 450);  

savings Account samir Account(account Number++, 9300);    

savings Account rita Account(account Number++, 32);



jack Account .deposit(1000);  

lisa Account.deposit(2300);    

samir Account.deposit(800);    

rita Account.deposit(500);



jack Account.postInterest();  

lisa Account.postInterest();

samir Account.postInterest();  

rita Account.postInterest();



     cout << \"***********************************\" << endl;    

jack Account.print();    

lisa Account.print();  

samir Account.print();

rita Account.print();    



cout << \"***********************************\" << endl << endl;

jack Account.writeCheck(250);  

lisa Account.writeCheck(350);    

samir Account.withdraw(120);    

rita Account.withdraw(290);


cout << \"********After withdrawals ***************\" << endl;  

jack Account.print();  

lisa Account.print();  

samir Account.print();  

rita Account.print();  

cout << \"***********************************\" << endl << endl;

return 0;
}

I was told the issue is in the BankAccount.h where the guards need to be moved around, but can\'t figure it out. Please help. //tester.cpp #include <iostream
I was told the issue is in the BankAccount.h where the guards need to be moved around, but can\'t figure it out. Please help. //tester.cpp #include <iostream
I was told the issue is in the BankAccount.h where the guards need to be moved around, but can\'t figure it out. Please help. //tester.cpp #include <iostream
I was told the issue is in the BankAccount.h where the guards need to be moved around, but can\'t figure it out. Please help. //tester.cpp #include <iostream
I was told the issue is in the BankAccount.h where the guards need to be moved around, but can\'t figure it out. Please help. //tester.cpp #include <iostream
I was told the issue is in the BankAccount.h where the guards need to be moved around, but can\'t figure it out. Please help. //tester.cpp #include <iostream
I was told the issue is in the BankAccount.h where the guards need to be moved around, but can\'t figure it out. Please help. //tester.cpp #include <iostream
I was told the issue is in the BankAccount.h where the guards need to be moved around, but can\'t figure it out. Please help. //tester.cpp #include <iostream
I was told the issue is in the BankAccount.h where the guards need to be moved around, but can\'t figure it out. Please help. //tester.cpp #include <iostream

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site