Question
Composition and Inheritance is to be used and Program is to be in C++ only. Question 2: Make UML diagram and program of following case.
Question 2: Make UML diagram and program of following case. (Marks 20+60=80)
Before start, please read it carefully
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. Customer should include name, account type and use member to credit or debit the balance in the specific account.
More specific types of accounts also exist. Savings accounts, for instance earn interest on the money account they can 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 doubleto 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 to0.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. [Note: Savings Account should inherit member functions credit and debit as is without redefining them.]
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).
[Hint: Define Accounts 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.]. Also make a class of Bank, it should include customer array and branch code, also make member function of customer list in which account details must be show. After defining the classes in this hierarchy, write a program that creates bank object and show all customers then call function of each class and tests their member functions. Add interest to the Savings Account object by first invoking it calculate Interest function, then passing the returned interest amount to the objects credit function.
Remember:
You can use extra function to complete your work.
Each class must have same name defined in given case.
Attributes must have appropriate name.
Marking distribution of program:
To identify and make class. (5)
To identify identifiers and member function of each class. (10)
To make correct relationship. (10)
No memory linkage in complete code. (10)
Screen shot of output with different aspects. (5)
To fulfil remember instruction. (2)
Complete code. (3)
Running without error with all aspects. (15)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started