Question
I need the code and QUESTIONS 1-5 Please !!!!! This is C++!!!! - Thank you !! PROJECT DESCRIPTION Write a program that contains various types
I need the code and QUESTIONS 1-5 Please !!!!! This is C++!!!! - Thank you !!
PROJECT DESCRIPTION Write a program that contains various types of bank account classes, and then displays a data report regarding each account. Ensure that your program is well designed and coded as a future project in this course will have you continue embellishing your bank account classes by supplementing them with program code to log sub-accounts to files based on various conditions, that is, you will write transactions to a file. Information about This Project This particular project uses the principles of inheritance and polymorphism.
Steps to Complete This Project
STEP 1 Implement Base Class Construction For this project, you will work with a base class called BankAccount to be defined as follows ////////////////////////////////////////////////////////////////// //// // class BankAccount // this is the abstract base class for all types of bank accounts ////////////////////////////////////////////////////////////////// //// class BankAccount { public : BankAccount(int = 0, float = 0); void deposit(float amount) { bal += amount; } int account_num() const { return acctnum; } float balance() const { return bal; } virtual void print() = 0; // a pure virtual function protected : int acctnum; float bal; }; ////////////////////////////////////////////////////////////////// //// // constructor for BankAccounts; both args can default to zero
BankAccount :: BankAccount(int num, float ibal) { acctnum = num; bal = ibal; }
PROJECT Polymorphism: BankAccount Class and sub classes
STEP 2 Implement Sub Class Constructions
Next, create two subaccounts namely for Checking and Savings which will inherit from the base class, BankAccount . Include the following details when constructing each class. - Include a Subaccount Constructor. The parameters for each constructor should call the base constructor passing an account number and a starter balance. - Include member functions called withdraw for each sub class. Ensure any withdrawal amounts passed in do not exceed the account balance. For checking account, charge a $ 0.50 per check fee for any amount falling below a $ 1,000 limit. - Include a print function for each sub class that when called, displays the account type, account number and account balance.
STEP 3 Test Your Code in the main() Function
-Create a checking account object and a savings account object. Pass starter account numbers and initial balances to each constructed object. -Include at least 2 deposits for each object and two withdraws as well. Include for the checking object at least one withdrawal outcome that will drop the balance below 1000. Include for the savings object, at least one withdrawal that attempts to drop the balance below 0. Your code should disallow this! -Run the print function for each account sub-type via a base class pointer.
Example
BankAccount* accounts[2]; // point to whatever your subaccount names are set as
accounts[0] = &checker; accounts[1] = &saver; // report on account balances for (int i = 0; i < 2; i++) accounts[i]->print();
PROJECT Polymorphism: BankAccount Class and sub classes
STEP 4 Snapshot your output.
Paste output of your run time processed in Word along with all your source for credit. _____________________________________________________________ STEP 5 Questions and Answers Concerning this Computer Project
Answer the following questions in your own words. Open MS Word and, within your lab submittal document, place your responses to each of these questions. Submit your completed MS Word document for credit.
(1) What does the following line in your base class mean? virtual void print() = 0; // pure virtual function
(2) If you were to log any checking accounts flagging penalty fees for passing the 1000 limit, how would you accomplish this writing to a file? What data would you write to the file for each incident?
(3) If you were to log any saving accounts that were flagging attempt to withdraw more than an existing balance (aka insufficient funds), how would you accomplish this writing to a file? What data would you write to the file for each incident?
(4) For this example on sub types what advantages come to mind due to this type of coding for polymorphic behavior?
(5) If you constructed a UML Class diagram for this application, how would the linkages connecting each class to the base appear?
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