Simple Multiple Inheritance

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Account Details

A bank provides two kinds of accounts to customers – Savings or Fixed. Some of the information like holder name,
account number, etc. are same for both the type of accounts. But the fixed account has some extra attributes like
the locking period. Bank wants to store the information of all the account holders in such a way that the common
information itself can be used somewhere if needed.

You are given the responsibility to develop an application for the above-mentioned requirements. Analysing the
factors you decide to opt for inheritance with Account class as parent and SavingAccount and FixedAccount as its
child classes.

Write a C++ program to get Fixed account details from the user and display the details using multilevel inheritance
with the following classes.
 
Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member
variable names, and function names should be the same as specified in the problem statement.
 
Consider a class Account with the following protected member variables.
Datatype Variable
String accountHolderName
String accountNumber
double balance
 
Consider a derived class SavingAccount derived from Account class with the following protected member variable.
Datatype Variable
double minimumBalance
 
Consider a derived class FixedAcocunt derived from SavingAccount class with the following private member variable,
Data type Member Name
Integer  lockingPeriod
 
Include the following member function in FixedAcocunt class
Member Function Description
This function is used to display the Account details.
Print the string "Account Details:" in the method itself. 
void display() Use "%-20s %-20s %-20s %-20s %s\n" to print the table header
"AccountHolderName","AccountNumber","Balance","MinimumBalance","LockingPeriod"
and to display the details in the order.
 
Consider a class AccountBO with the following public member function,
Member Function Description
The method accepts all the detail as a parameter,
FixedAccount accountDetails(string details)
split the detail and store it in fixedAccount type object and returns that object.
 
In the main method, the detail of the FixedAccount is obtained from the user as a comma-separated value.
Split the details by calling the accountDetails method and create an object for FixedAccount and display the
details in the specified format.
 
Input  format:
The account detail should be given in the CSV format
[accountHolderName,accountNumber,balance,minimumBalance,lockingPeriod]
Output format:
The output consists of fixed account detail. 
Use "%-20s %-20s %-20.2f %-20.2f %d\n" this format to print the detail.
Refer sample Input and output for formatting specifications.
[All text in bold corresponds to input and the rest corresponds to output]
Sample Input and Output:
Enter account details
Tony,ACC001,5456.45,500,10
Account Details:
AccountHolderName  AccountNumber         Balance          MinimumBalance    LockingPeriod
Tony                            ACC001                     5456.45           500.00                     10
 

You might also like