29 Jul (POLYMORPHIC BANKING PROGRAM USING ACCOUNT HIERARCHY
(Polymorphic Banking Program Using Account Hierarchy) Develop a polymorphic banking program using the Account hierarchy created in Exercise 20.10. Create a vector of Account pointers to Savings Account and Checking Account 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 Savings Account calculate the amount of interest owed to the Account using member function calculate Interest 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 get Balance. Exercise 20.10 (Account Inheritance Hierarchy) Create an inheritance hierarchy that a bank might use to represent customers bank accounts. All customers at this bank can deposit (i.e. credit) money into their accounts and withdraw (i.e. debit) money from their accounts. More specific types of accounts also exist. Savings accounts for instance earn interest on the money they hold. Checking accounts on the other hand charge a fee per transaction (i.e. credit or debit). Create an inheritance hierarchy containing base class Account and derived classes Savings Account and Checking Account that inherit from class Account. Base class Account should include one data member of type double to represent the account balance. The class should provide a constructor that receives an initial balance and uses it to initialize the data member. The constructor should validate the initial balance to ensure that its greater than or equal to 0.0. If not the balance should be set to 0.0 and the constructor should display an error message indicating that the initial balance was invalid. The class should provide three member functions. Member function credit should add an amount to the current balance. Member function debit should withdraw money from the Account and ensure that the debit amount does not exceed the Accounts balance. If it does the balance should be left unchanged and the function should print the message Debit amount exceeded account balance. Member function get Balance should return the current balance. Derived class Savings Account should inherit the functionality of an Account but also include a data member of type double indicating the interest rate (percentage) assigned to the Account. Savings Accounts constructor should receive the initial balance as well as an initial value for the Savings Accounts interest rate. Savings Account should provide a public member function calculate Interest that returns a double indicating the amount of interest earned by an account. Member function calculate Interest should determine this amount by multiplying the interest rate by the account balance. Derived class Checking Account should inherit from base class Account and include an additional data member of type double that represents the fee charged per transaction. Checking Accounts constructor should receive the initial balance as well as a parameter indicating a fee amount. Class Checking Account should redefine member functions credit and debit so that they subtract the fee from the account balance whenever either transaction is performed successfully. Checking Accounts versions of these functions should invoke the base-class Account version to perform the updates to an account balance. Checking Accounts debit function should charge a fee only if money is actually withdrawn (i.e. the debit amount does not exceed the account balance). After defining the classes in this hierarchy write a program that creates objects of each class and tests their member functions. Add interest to the Savings Account object by first invoking its calculate Interest function then passing the returned interest amount to the objects credit function.
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.
