Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Question: (Polymorphic Banking Program Using Account Hierarchy) Develop a polymorphic banking program using the Account hierarchy created in Exercise. 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: (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 it's 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 Account's 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 Account's constructor should receive the initial balance, as well as an initial value for the Savings Account's 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 Account's 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 Account's versions of these functions should invoke the base-class Account version to perform the updates to an account balance. Checking Account's 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 object's credit function.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92419016
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Question recall the optimal page replacement algorithmthe

Question : Recall the optimal page replacement algorithm. The victim page chosen by the algorithm is the one that will not be used the longest period of time. Can this algorithm exhibit Belady's anomaly? Justify your ans ...

The below figure represents the potential outcomes of your

The below figure represents the potential outcomes of your first salary negotiation after graduation. Assuming this is a sequential-move game with the employer moving first, indicate the most likely outcome. Does the abi ...

Question suppose we are given a chain of n nodes as shown

Question : Suppose we are given a "chain" of n nodes as shown below. Each node i is "neighbors" with the node to its left and the node to its right (if they exist). An independent set of these nodes is a subset of the no ...

Question bull what is the significance of the concept of

Question : • What is the significance of the concept of inheritance within the concept of object oriented programming? How does the concept of inheritance improve on the traditional programming model? • Provide a program ...

A sample of 1000 us households is taken and the average

A sample of 1,000 U.S. households is taken and the average amount of newspaper garbage or recycling is found to be 27.8 pounds. Assuming the standard deviation of newspaper for garbage or recycling is 2 pounds. Estimate, ...

It is required to design an iterative combinational circuit

It is required to design an iterative combinational circuit that computes the equation Z=2*X-Y, where X and Y are n-bit unsigned numbers. (i) Determine the number of inputs and outputs needed for your 1-bit cell. (ii) De ...

Problem belowwrite a program that uses a function that

Problem below: Write a program that uses a function that returns a number between 1 and 6. Use this function to simulate the roll of a die. Allow the user to specify the number of trials and then tabulate that number of ...

Question suppose you want to achieve a speedup of 90 times

Question : Suppose you want to achieve a speedup of 90 times faster with 100 processors. What percentage of the original computation can be sequential? Assume one byte data value is 1101, 1000(binary). When we decode the ...

Discuss why a financial services organization would benefit

Discuss why a financial services organization would benefit from using one framework over another (COSO, COBIT,) -- choose a framework or frameworks that in your opinion would be most ideally suited for such an organizat ...

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As