Question: Create a C++ project to do implement a simplified functionalities of a Banking scheme. Step 1: Create a header file Bank.h to define a Bank
Create a C++ project to do implement a simplified functionalities of a Banking scheme.
Step 1:
Create a header file Bank.h to define a Bank class with the following members:
Data members: The program should implement data hiding, so please define data members accordingly.
- int ccountNumber
- double balance
- char * owner
Note: The owner means the full name (first and last name).
Member functions: Include only the declaration (prototype) of the member functions in the header file. The implementation of member functions will later be done in the Bank.cpp file.
- Bank() constructor with no arguments to create a bank account with a default
accountNumber as 9999 and balance value of zero.
- Bank(param1, param2) constructor with two parameters to create a bank account
with a specified accountNumber and balance (as param1 and param2, respectively), set the owner data member to nullptr.
- withdraw(param1) function to withdraw a specified amount (param1) from the
account. The function should first check if there is sufficient balance in the account. If the balance is sufficient, withdrawal is processed, otherwise display a message to the user that says Insufficient balance. and withdraw his complete balance so that balance becomes zero.
- deposit(param1) function to deposit a specified amount of money (param1) to
the account.
- getAccountNumber(): An accessor function that returns the account number. This
function is later called by the displayAccountInfo(). Please note that displayAccountInfo() IS NOT a member function of the Bank class.
-getBalance(): An accessor function that returns the account balance. This function is
later called by the displayAccountInfo() function. Please note that displayAccountInfo() IS NOT a member function of the Bank class.
-getOwner(): An accessor function that returns the full name of the account owner. This function is later called by the displayAccountInfo(). Please note that displayAccountInfo() IS NOT a member function of the Bank class.
-Write all the mutators needed to set the three data member values. Note: owner is a c-string, therefore you will need to make sure you dynamically allocate memory for it; and write the destructor to release the memory allocated for the owner c-string.
Step 2:
Create a Bank.cpp file and define the member functions of the Bank class.
Step 3:
Also define an independent displayAccountInfo(Bank obj) function which takes a Bank object (obj) as a parameter and displays the accountNumber, balance and owner of the bank account specified by this Bank object. For this, it calls the getAccountNumber(), getBalance() and getOwner() member functions of the Bank class.
Note: The displayAccountInfo() function IS NOT a member function of the Bank class. It is an independent function that is called from inside the main function.
Step 4:
Finally, create a main.cpp file to do the following:
- Create a dynamic bank account say accnt1- with no parameters. Try to withdraw $500 from this account.
- Then display the account information for this account by calling the displayAccountInfo() function once with parameter accnt1.
-
- Delete accnt1. Now dynamically allocate memory for another instance with accountNumber: 1111, $1000 balance and owner John Smith. Withdraw $600, then withdraw $300, and then deposit $400 to this account.
-Then display the account information for this account by calling the displayAccountInfo() function once with parameter accnt1.
- Write a friend function called accountInfo() to display all the account parameters, without having to use the accessors as in displayAccountInfo()
-Then display the account information for this account by calling the accountInfo () function once with parameter accnt1.
There are other questions very similar to this with answers that include a checking and savings account which is not what the project is looking for.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
