Write an app that creates objects

Assignment Help C/C++ Programming
Reference no: EM131447100

Who can figure out this Exercise for me

(Bank 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.

Create base class BankAccount and derived classes SavingsAccount and CheckingAccount that inherit from class BankAccount. Base class BankAccount should include one private instance variable of type decimal to represent the account balance. The class should provide a constructor that receives an initial balance and uses it to initialize the instance variable with a public property. The property should validate the initial balance to ensure that it's greater than or equal to 0.0; if not, throw an exception. The class should provide two public methods. Method Deposit should add an amount to the current balance. Method Withdraw 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 method should display the message "Debit amount exceeded account balance."

Derived class SavingsAccount should inherit the functionality of BankAccount, but also include a decimal instance variable indicating the interest rate (percentage) assigned to the Account. SavingsAccount's constructor should receive the initial balance, as well as an initial value for the interest rate. SavingsAccount should provide public method CalculateInterest that returns a decimal indicating the amount of interest earned by an account. Method CalculateInterest should determine this amount by multiplying the interest rate by the account balance. [Note: SavingsAccount should inherit methods Deposit and Withdraw without redefining them.]

Derived class CheckingAccount should inherit from base class BankAccount and include a decimal instance variable that represents the fee charged per transaction. CheckingAccount's constructor should receive the initial balance, as well as a parameter indicating a fee amount. Class CheckingAccount should redefine methods Deposit and Withdraw so that they subtract the fee from the account balance whenever either transaction is performed successfully. CheckingAccount's versions of these methods should invoke the base-class Account version to perform the updates to an account balance. CheckingAccount's Withdraw method should charge a fee only if money is actually withdrawn (i.e., the debit amount does not exceed the account balance). [Hint: Define BankAccount's Withdraw method so that it returns a bool indicating whether money was withdrawn. Then use the return value to determine whether a fee should be charged.]

After defining the classes in this hierarchy, write an app that creates objects of each class and tests their methods. Add interest to the SavingsAccount object by first invoking its CalculateIn- terest method, then passing the returned interest amount to the object's Deposit method.

Verified Expert

This paper is about the C++ program to create an inheritance hierarchy using banking system. It is used to represent customer’s bank account where all customers can deposit or withdraw the money from their respective accounts. The super class called BankAccount is used to describe the methods Deposit and Withdraw. This paper also specifies two types of account namely SavingsAccountwhich lets the user earn interest on the money they hold. On the other hand is the CheckingsAccount which charge a fee per transaction i.e on deposit and withdrawal.

Reference no: EM131447100

Questions Cloud

What could you do to work collaboratively : How are human services professionals similar to and different from other professionals who work in the same agency? How are they similar to and different from non-professional helpers (e.g., volunteers) who work in the same agency? What could you ..
Freely floating or dirty floating exchange rate system : If you were elected to choose between a fixed, freely floating or dirty floating exchange rate system, which would you choose for your home country? Why? China has a fixed exchange rate for the yuan (the currency they use for foreign trade). Many peo..
Calculate the market-to-book ratio and price-earnings ratio : You are considering an investment in Roxie's Bed & Breakfast Corp. During the last year, the firm's income statement listed an addition to retained earnings of $12.60 million and common stock dividends of $1.90 million. What is Roxie's Bed & Breakfas..
Discuss the asset allocation for robustnees : Discuss the asset allocation for robustnees. What is the resulting duration gap between liabilities and assets? How well is the fund protected in both risk scenario's? Calculate the impact on the cover ratio of the two risk scenario's that form th..
Write an app that creates objects : Write an app that creates objects of each class and tests their methods. Add interest to the SavingsAccount object by first invoking its CalculateIn- terest method, then passing the returned interest amount to the object's Deposit method.
Complete the post of good news messages : Message Strategies: Good News Messages. Amateur and professional golfers in search of lower scores want to find clubs that are optimized for their individual swings.
Treating persons who meet the criteria for substance abuse : Compare the 4-stage recovery model to the harm reduction model for treating persons who meet the criteria for substance abuse. What are the strengths and the weaknesses of each model?
What is pay for performance : What is "pay for performance"? Do pay for performance plans make organizations more effective? How should organizations make pay for performance work for them?
What do you think it is like to work at the agency : Go sit in the waiting room of a human services agency in your community. If you are not able to visit an agency in person, refer to one of the agencies featured in one of the optional resources for the module (Bringing Storytime to the Long Wait f..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a function that accepts an int array

The task calls for: Write a function that accepts an int array and the array's size as arguments. The function should create a copy of the array, except that the element values should be reversed in the copy. The function should return a pointer t..

  Prepare a program for sorting the numbers

Write a program that orders three double numbers by increasing value. The program should include a function named sort3 that takes three double * arguments (pointer to double). The function prototype is void sort3(double *x, double *y, double *z);

  Three or more dimensions

What kind of program, or problem, might necessitate arrays of three or more dimensions?

  Find the prime numbers

Write a c++ program to find the prime numbers

  Write a small program scropy

You are supposed to write a small program scropy, which takes two arguments on the command line: the names of a source file and a destination file.

  Creating a part number

Write C++ program that asks a user to enter a part number to order. The rules for creating a part number are as follows:

  Perform operations-add, delete and replace

Now given a string S, you can perform operations, namely, add, delete and replace of any character present in the string - Every operation will consists of following costs

  Consider implementing subnetting to support three department

Consider implementing subnetting to support three departments within an organization. The three departments P, Q and R need support for 30, 40 and 60 hosts.

  Calculate the total volume for all three boxes

Calculate the total volume for all three boxes in question.Add a third box to the calculation.

  Store user input - write c++ program

Write C++ program to provide the following functionality - Ask users to enter 10 integer numbers.

  Write a program in c that arranges and prints out

When playing poker and other card games (standard 52 cards, excluding the jokers), it is usual to arrange a hand to reflect its values. Write a program in C that arranges and prints out a random hand of ten cards in sorted order by pips values.

  Using songs.dat in our folder

Using songs.dat in our folder on the P: drive, construct a playlist of 10 random songs. Use a struct to hold the song data (name and time in seconds), and output the playlist (song name and time,

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd