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

Need to get the following output by Editing ChekingAccount.h ,ChekingAccount.cpp

ID: 3807886 • Letter: N

Question

Need to get the following output by Editing ChekingAccount.h ,ChekingAccount.cpp

CheckingAccount

Derived class CheckingAccount that inherits from base class Account and include an additional data member of type double that represents the fee charged per transaction (transactionFee).

Write Checking- Account’s constructor that receives the initial balance, as well as a parameter indicating a transaction fee amount. If transaction fee is less than zero, the transactionFee will be set to zero.

Write the chargeFee member function that updates the balance by deducting the transactionFee from the balance.

Override member functions debit for class CheckingAccount so that it subtracts the transactionFee from the account balance (call chargeFee). If the operation is successful, it will return true otherwise it does nothing and will return false (debit is successful if the amount is not greater than the balance). CheckingAccount’s versions of this function should invoke the base-class Account version to perform the debit operation.

Hint: Define Account’s debit function so that it returns a bool indicating whether money was withdrawn. Then use the return value to determine whether a fee should be charged.

Override member functions credit for class CheckingAccount so that it subtracts the transactionFee from the account balance (call chargeFee). CheckingAccount’s versions of this function should invoke the base-class Account version to perform the credit operation.

Override the display function in the Account class that insert that print a SavingsAccount in the following format (example):

Account.h:

#ifndef ICT_ACCOUNT_H__
#define ICT_ACCOUNT_H__

#include

using namespace std;
namespace ict
{
    class Account
    {
       private:
           double balance; // data member that stores the balance
       protected:
           double getBalance() const; // return the account balance
           void setBalance( double ); // sets the account balance
       public:
           // TODO: Write a prototype for constructor which initializes balance
           Account(double);
           // TODDO: Write a function prototype for the virtual function credit
           virtual void credit(double);
           // TODO: Write a function prototype for the virtual function debit
           virtual bool debit(double);
           // TODO: Write a function prototype for the virtual function display
           // Add the prototype of pure virtual function display that receives a reference to ostream.
           virtual void display(ostream &) = 0;
    };
};
#endif

Account.cpp:

#include "Account.h"

using namespace std;
namespace ict
{
    // constructor
    // Write the constructor that validates the initial balance to ensure that it’s greater
    // than or equal to 0. If not, set the balance to the safe empty state
    // (balance equals to -1.0).
    Account::Account(double bal)
    {
       if(bal >= 0)
           balance = bal;
       else
           balance = -1.0;  
    }
   
    // credit (add) an amount to the account balance
    //Write the virtual member function credit that adds an amount to the current balance.
    void Account::credit(double amount)
    {
       balance += amount;
    }
   
    // debit (subtract) an amount from the account balance return bool
    // Write the virtual member function debit that withdraws money from the account and
    // ensure that the debit amount does not exceed the Account’s balance. If the balance
    // is less the amount, the balance should be left unchanged and the function should
    // return false (otherwise it should return true).
    bool Account::debit(double amount)
    {
       if(amount > balance)
           return false;
       balance -= amount;
       return true;  
    }
   
    double Account::getBalance() const   {   return balance;   }
    void Account::setBalance( double newBalance )   {   balance = newBalance;   }
}

SavingsAccount.h:

#ifndef ICT_SAVINGSACCOUNT_H__
#define ICT_SAVINGSACCOUNT_H__
#include "Account.h"

using namespace std;

namespace ict
{
    class SavingsAccount : public Account
    {
       private:
           double interestRate; // interest rate (percentage)
       public:
           // TODO: put prototypes here
           SavingsAccount(double bal, double interest);
           double calculateInterest();
           void display(ostream&);
    };
};
#endif

SavingsAccount.cpp:

#include "SavingAccount.h"
#include
using namespace std;

namespace ict
{
    // TODO: Implement SavingsAccount member functions here
    // Write the SavingsAccount’s constructor that receives the initial balance, as well
    // as an initial value for the SavingsAccount’s interest rate, and then initializes
    // the object. If interest rate is less than zero, the interstRate will be set to zero.
    SavingsAccount::SavingsAccount(double bal, double interest) : Account(bal)
    {
       if(interest < 0)
           interestRate = 0;
       else
           interestRate = interest;
    }
    // Write the public member function calculateInterest for SavingsAccount class that
    // returns the amount of interest earned by an account. Member function
    // calculateInterest should determine this amount by multiplying the interest rate
    // by the account balance.
    double SavingsAccount::calculateInterest()
    {
       return interestRate * getBalance();
    }
    void SavingsAccount::display(ostream &out)
    {
       out << "Account type: Saving" << endl;
       out << "Balance: $ " << fixed << setprecision(2) << getBalance() << endl;
       out << "interest Rate (%): " << fixed << setprecision(2) << interestRate * 100 << endl;
    }  
}

Main.cpp

#include

#include "Account.h"

#include "SavingsAccount.h"

#include "CheckingAccount.h"

using namespace ict;

using namespace std;

int main()

{

     // Create Account for Angelina

     Account * Angelina_Account[2];

   

     // initialize Angelina Accounts

    

     Angelina_Account[ 0 ] = new SavingsAccount( 400.0, 0.12 );

     Angelina_Account[ 1 ] = new CheckingAccount( 400.0, 1.0);

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

     cout << "DISPLAY Angelina Accounts:" << endl;

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

     Angelina_Account[0]->display(cout);

     cout << "-----------------------" << endl;

     Angelina_Account[1]->display(cout);

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

     cout << "DEPOSIT $ 2000 $ into Angelina Accounts ..." << endl ;

     for(int i=0 ; i < 2 ; i++){

         Angelina_Account[i]->credit(2000);

     }

     cout << "WITHDRAW $ 1000 and $ 500 from Angelina Accounts ..." << endl;

     Angelina_Account[0]->debit(1000);

     Angelina_Account[1]->debit(500);

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

     cout << "DISPLAY Angelina Accounts:" << endl;

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

     Angelina_Account[0]->display(cout);

     cout << "-----------------------" << endl;

     Angelina_Account[1]->display(cout);

     cout << "-----------------------" << endl;

     return 0;

}

The following is the exact output of the tester program:

DISPLAY Angelina Accounts:

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

Account type: Saving

Balance: $ 400.00

Interest Rate (%): 12.00

-----------------------

Account type: Checking

Balance: $ 400.00

Transaction Fee: 1.00

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

DEPOSIT $ 2000 $ into Angelina Accounts ...

WITHDRAW $ 1000 and $ 500 from Angelina Accounts ...

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

DISPLAY Angelina Accounts:

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

Account type: Saving

Balance: $ 1400.00

Interest Rate (%): 12.00

-----------------------

Account type: Checking

Balance: $ 1898.00

Transaction Fee: 1.00

-----------------------

ChekingAccount.cpp

}

ChekingAccount.h

#endif

#include "CheckingAccount.h"

Explanation / Answer

#ifndef ACCOUNT_H #define ACCOUNT_H class Account { public: Account( double ); // constructor initializes balance void credit( double ); // add an amount to the account balance bool debit( double ); // subtract an amount from the account balance void setBalance( double ); // sets the account balance double getBalance(); // return the account balance private: double balance; // data member that stores the balance }; // end class Account #endif // Account.cpp // Member-function definitions for class Account. #include using namespace std; #include "Account.h" // include definition of class Account // Account constructor initializes data member balance Account::Account( double initialBalance ) { // if initialBalance is greater than or equal to 0.0, set this value // as the balance of the Account if ( initialBalance >= 0.0 ) balance = initialBalance; else // otherwise, output message and set balance to 0.0 { cout
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