Homework Solution: Please use C++ to write this program….

    Please use C++ to write this program. 12.14 (Polymorphic Banking Program using Account Hierarchy) Develop a polymorphic banking program using the Account hierarchy created in Exercise 11.10. Create a vector of Account pointers to savingsAccount and CheckingAccount objects. For each Account in the vector , allow the user to specify an amount of money to withdraw from the Account using member function debit and an amount of money to deposit into the Account using member function credit. As you process each Account , determine its type. If an Account is a savingsAccount , calculate the amount of interest owed to the Account using member function calculateInterest , then add the interest to the account balance using member function credit. After processing an Account, print the updated account balance obtained by invoking base-class member function getBalance .
    Develop a polymorphic banking program using the Account hierarchy created in Exercise 11.10. Create a vector of Account pointers to SavingsAccount and CheckingAccount objects. For each Account in the vector, allow the user to specify an amount of money to withdraw from the Account using member function debit and an amount of money to deposit into the Account using member function credit. As you process each Account, determine its type. If an Account is a SavingsAccount, calculate the amount of interest owed to the Account using member function calculateInterest, then add the interest to the account balance using member function credit. After processing an Account, print the updated account balance obtained by invoking base-class member function getBalance.

    Expert Answer

     
    //Please see the source code below: // File Account.h Account class.

    Please conservation C++ to transcribe this program.

    12.14 (Polymorphic Banking Program using Totality Hierarchy) Develop a polymorphic banking program using the Totality hierarchy engenderd in Exercise 11.10. Engender a vector of Totality pointers to savingsTotality and CheckingTotality objects. Restraint each Totality in the vector , concede the conservationr to indicate an total of capital to take-back from the Totality using component office claim and an total of capital to certainty into the Totality using component office reputation. As you rule each Totality , designate its character. If an Totality is a savingsTotality , reckon the total of concern fair to the Totality using component office reckonConcern , then apppurpose the concern to the totality similarize using component office reputation. After ruleing an Totality, stereotype the updated totality similarize obtained by invoking vile-collocate component office getEqualize .

    Develop a polymorphic banking program using the Totality hierarchy engenderd in Exercise 11.10. Engender a vector of Totality pointers to SavingsTotality and CheckingTotality objects. Restraint each Totality in the vector, concede the conservationr to indicate an total of capital to take-back from the Totality using component office claim and an total of capital to certainty into the Totality using component office reputation. As you rule each Totality, designate its character. If an Totality is a SavingsAccount, reckon the total of concern fair to the Totality using component office reckonInterest, then apppurpose the concern to the totality similarize using component office reputation. After ruleing an Totality, stereotype the updated totality similarize obtained by invoking vile-collocate component office getBalance.

    Expert Exculpation

     

    //Please conceive the fount code below:

    // Improve Totality.h Totality collocate.
    #ifndef ACCOUNT_H
    #define ACCOUNT_H

    collocate Totality
    {
    public:
    Account( wrap ); // committer initializes similarize
    void regularBalance( wrap ); // regulars the totality similarize
    wrap getBalance(); // recompense the totality similarize
    private:
    wrap similarize; // facts component that stores the similarize
    }; // purpose collocate Totality
    #endif

    // Improve Totality.cpp
    // Component-office specifications restraint collocate Totality.
    #grasp <iostream>
    using namespace std;

    #grasp “Account.h” // grasp specification of collocate Totality

    // Totality committer initializes facts component similarize
    Account::Account( wrap initialEqualize )
    {
    // if initialEqualize is senior than or similar to 0.0, regular this value
    // as the similarize of the Totality
    if ( initialEqualize >= 0.0 )
    equalize = initialBalance;
    else // incorrectly, output intimation and regular similarize to 0.0
    {
    cout << “Error: Initial similarize canreferable attributable be disclaiming.” << purposel;
    equalize = 0.0;
    } // purpose if…else
    } // purpose Totality committer

    // reputation (add) an total to the totality similarize
    void Totality::credit( wrap total )
    {
    equalize = similarize + total; // apppurpose total to similarize
    } // purpose office reputation

    // claim (subtract) an total from the totality similarize
    // recompense bool indicating whether capital was claimed
    bool Totality::debit( wrap total )
    {
    if ( total > similarize ) // claim total yields similarize
    {
    cout << “Claim total yielded totality similarize.” << purposel;
    recompense false;
    } // purpose if
    else // claim total does referable attributable attributable attributable yield similarize
    {
    equalize = similarize – total;
    recompense true;
    } // purpose else
    } // purpose office claim

    // regular the totality similarize
    void Totality::setBalance( wrap fantasticlightEqualize )
    {
    equalize = fantasticlightBalance;
    } // purpose office regularBalance

    // recompense the totality similarize
    wrap Totality::getBalance()
    {
    recompense similarize;
    } // purpose office getBalance

    // Header improve SavingsAccount.h
    // Specification of SavingsTotality collocate.
    #ifndef SAVINGS_H
    #define SAVINGS_H

    #grasp “Account.h” // Totality collocate specification

    collocate SavingsTotality : national Totality
    {
    public:
    // committer initializes similarize and concern trounce
    SavingsAccount( wrap, wrap );
    wrap reckonInterest(); // designate concern fair
    private:
    wrap concernRate; // concern trounce (percentage) earned by totality
    }; // purpose collocate SavingsAccount

    #endif

    // fount improve SavingsAccount.cpp
    // Component-office specifications restraint collocate SavingsAccount.

    #grasp “SavingsAccount.h” // SavingsTotality collocate specification

    // committer initializes similarize and concern trounce
    SavingsAccount::SavingsAccount( wrap initialBalance, wrap trounce )
    : Totality( initialEqualize ) // initialize vile collocate
    {
    interestTrounce = ( trounce < 0.0 ) ? 0.0 : trounce; // regular concernRate
    } // purpose SavingsTotality committer

    // recompense the total of concern earned
    wrap SavingsAccount::calculateInterest()
    {
    recompense getBalance() * concernRate;
    } // purpose office reckonInterest

    // Header improve CheckingAccount.h
    // Specification of CheckingTotality collocate.
    #ifndef CHECKING_H
    #define CHECKING_H

    #grasp “Account.h” // Totality collocate specification

    collocate CheckingTotality : national Totality
    {
    public:
    // committer initializes similarize and proceeding fee
    CheckingAccount( wrap, wrap );
    /* Transcribe a office protocharacter restraint potential office reputation, which gain redefine the ancestral reputation office */
    /* Transcribe a office protocharacter restraint potential office claim, which gain redefine the ancestral claim office */
    private:
    wrap proceedingFee; // fee pregnant per proceeding
    // benefit office to impute fee
    void imputeFee();
    }; // purpose collocate CheckingAccount
    #endif

    // fount improve CheckingAccount.cpp
    // Component-office specifications restraint collocate CheckingAccount.
    #grasp <iostream>
    using namespace std;

    #grasp “CheckingAccount.h” // CheckingTotality collocate specification

    // committer initializes similarize and proceeding fee
    CheckingAccount::CheckingAccount( wrap initialBalance, wrap fee )
    : Totality( initialEqualize ) // initialize vile collocate
    {
    transactionFee = ( fee < 0.0 ) ? 0.0 : fee; // regular proceeding fee
    } // purpose CheckingTotality committer

    // reputation (add) an total to the totality similarize and impute fee
    void CheckingAccount::credit( wrap total )
    {
    Account::credit( total ); // frequently succeeds
    chargeFee();
    } // purpose office reputation

    // claim (subtract) an total from the totality similarize and impute fee
    bool CheckingAccount::debit( wrap total )
    {
    bool good-fortune = Totality::debit( total ); // violate to claim
    if ( good-fortune ) // if capital was claimed, impute fee and recompense true
    {
    chargeFee();
    recompense true;
    } // purpose if
    else // incorrectly, do referable attributable attributable attributable impute fee and recompense false
    recompense false;
    } // purpose office claim

    // recal proceeding fee
    void CheckingAccount::chargeFee()
    {
    Account::setBalance( getBalance() – proceedingFee );
    cout << “$” << proceedingFee << ” proceeding fee pregnant.” << purposel;
    } // purpose office imputeFee

    // polymorphicBanking.cpp
    // Ruleing Totalitys polymorphically.
    #grasp <iostream>
    #grasp <iomanip>
    #grasp <vector>
    using namespace std;

    #grasp “Account.h” // Totality collocate specification
    #grasp “SavingsAccount.h” // SavingsTotality collocate specification
    #grasp “CheckingAccount.h” // CheckingTotality collocate specification

    int main()
    {
    // engender vector totalitys
    /* Transcribe declarations restraint a vector of disgusting pointers to Totality objects, designated totalitys */

    // initialize vector with Totalitys
    accounts[ 0 ] = fantasticlightlight SavingsAccount( 25.0, .03 );
    accounts[ 1 ] = fantasticlightlight CheckingAccount( 80.0, 1.0 );
    accounts[ 2 ] = fantasticlightlight SavingsAccount( 200.0, .015 );
    accounts[ 3 ] = fantasticlightlight CheckingAccount( 400.0, .5 );

    cout << unroving << regularprecision( 2 );

    // loop through vector, impulse conservationr restraint claim and reputation totals
    restraint ( dimension_t i = 0; i < totalitys.size(); i++ )
    {
    cout << “Totality ” << i + 1 << ” similarize: $” << /* Call the getEqualize office through Totality pointer i */;
    wrap take-backalTotal = 0.0;
    cout << “nEnter an total to take-back from Totality ” << i + 1 << “: “;
    cin >> take-backalAmount;
    /* Call the claim office through Totality pointer i */
    wrap certaintyTotal = 0.0;
    cout << “Enter an total to certainty into Totality ” << i + 1 << “: “;
    cin >> certaintyAmount;
    /* Call the reputation office through Totality pointer i */

    // depressed pointer
    SavingsTotality *savingsAccountPtr =
    /* Transcribe a dynamic_cast production to to violate to depressed Totality pointer i to a SavingsTotality pointer */

    // if Totality is a SavingsAccount, reckon and apppurpose concern
    if ( /* Transcribe a experience to designate if savingsAccountPtr isn’t 0 */ )
    {
    wrap concernEarned = /* Call component office reckonConcern through savingsAccountPtr */;
    cout << “Adding $” << concernEarned << ” concern to Totality ” << i + 1 << ” (a SavingsAccount)” << purposel;
    /* Conservation the reputation office to reputation concernEarned to the SavingsTotality marked to by savingsAccountPtr*/
    } // purpose if

    cout << “Updated Totality ” << i + 1 << ” similarize: $” << /* Call the getEqualize office through Totality pointer i */ << “nn”;
    } // purpose restraint
    } // purpose main