Your SlideShare is downloading. ×
Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7
Comp 220 ilab 3 of 7
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Comp 220 ilab 3 of 7

184

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
184
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. COMP/220 iLab 3 of 7 - C++ CourseiLABOVERVIEWScenario and SummaryThis lab introduces you to writing a C++ program to implement the concept of class inheritanceusing different types of bank accounts as a model. In this lab, you will create a base class, calledCBankAccount, and two additional classes (each derived from CBankAccount), calledCSavingsAccount and CCheckingAccount. You will then test the operations of each class in functionmain() to simulate the transactions of both a checking account and a savings account.Deliverables1. Submit a single Notepad file containing the source code for all the files of the lab to theDropbox for Week 3. Your source code should use proper indentation and be error free. Be sure thatyour last name and the lab number are part of the file name: for example, YourLastName_Lab3.txt.Each program should include a comment section that includes (minimally) your name, the lab andexercise number, and a description of what the program accomplishes.2. Submit a lab report (a Word document) containing the following information to theDropbox for Week 3.o Include your name and the lab or lab-exercise number.o Specification: Include a brief description of what the program accomplishes, including itsinput, key processes, and output.o Test Plan: Include a brief description of the method you used to confirm that yourprogram worked properly. If necessary, include a clearly labeled table with test cases, predictedresults, and actual results.o Summary and Conclusions: Includea summary of what the lab demonstrated and anyconclusions drawn from the testing of the lab program.o Provide a UML diagram showing the base and the derived class relationships, accessspecifiers, data types, and function arguments.o Answers to Lab Questions: Answer any and all of the lab questions included in the labsteps.Summary: Write a statement summarizing your predicted and actual output. Identify and explainany differences.
  • 2. Conclusions: Write at least one nontrivial paragraph that explains, in detail, either a significantproblem you had and how you solved it or, if you had no significant problems, something youlearned by doing the exercise.Each lab exercise should have a separate section in the lab-report document.Your lab grade is based upon1. the formatting of your source code;2. the use of meaningful identifiers;3. the extent of internal documentation;4. the degree to which an exercises’ specifications are met; and5. the completeness of your lab report.iLABSTEPSSTEP 1: Create the Multifile Project and the Main (Base) ClassCreate a new project that consists of the base class BankAccount.The BankAccount class should contain, at minimum, the following members.1. It should contain data members to store a bank customers balance and account number.These should be of different and appropriate data types.2. It should have function members that do the following:a. set the account number;b. return the account number;c. return the account balance;d. deposit money into the account; ande. withdraw money from the account.STEP 2: Create the CheckingAccount Class Derived From the BankAccount ClassThe class CheckingAccount should contain, at a minimum, the following members.1. It should contain a data member to keep track of the number of withdrawal transactionsmade on the account. Whenever a withdrawal is made, this number should be incremented.2. Override the base class, withdraw-money function, and add the capability to deducttransaction fees from an account using the following guidelines.a. The checking account is allowed three free transactions. For each successful withdrawaltransaction past the three free transactions, there will be a service fee of 50 cents per transaction.The service fee should be deducted from the account balance at the time the transaction is made.
  • 3. b. If there are insufficient funds in the account balance to cover the withdrawal plus theservice fee, the withdrawal should be denied.c. The function should return a value to indicate whether the transaction succeeded orfailed. Transaction fees should be deducted only from successful transactions, but the transactioncount should be incremented in either case.STEP 3: Create the SavingsingAccount Class Derived From the BankAccount ClassThe class CheckingAccount should contain, at a minimum, the following members.1. It should contain a data member to hold the daily interest rate. The daily interest rate canbe calculated from a yearly interest rate by dividing the annual rate by 365.2. It should contain a data member to keep track of the number of days since the lasttransaction or balance inquiry. This should be updated using a random-number generator (referenceLab 1) that will return a value representing the number of days between 0 and 7, inclusive. We willassume that this bank is open every day of the year.3. It should contain a data member to hold the interest earned since the last transaction orbalance inquiry.4. It should contain a function member to set the annual interest rate.5. Utilize the base-class functions for both withdrawal and deposit operations for the savingsaccount.6. Override the base-class-balance inquiry function to add calculating and adding interest tothe account based on the daily interest rate, the current balance of the account, and the number ofdays since the last balance inquiry. This should be called only when a balance inquiry is made, notwhen a deposit or withdrawal transaction or an account number inquiry is made.7. If there are insufficient funds in the account balance to cover a withdrawal, thewithdrawal should be denied. The number of days since the last transaction or balance inquiry andthe interest calculations should still be made.8. A value should be returned to indicate whether a withdrawal transaction succeeded orfailed.9. It should contain a function member to return the interest earned since the lasttransaction or balance inquiry.10. It should contain a function member to return the number of days since the lasttransaction or balance inquiry.STEP 4: Test Program Operation1. All data-input and data-display operations (cin and cout) should be done in the functionmain() test program.2. The test program should create one checking account and one savings account with initialbalances of $100 each using the functions defined in the class definitions. The test program should
  • 4. also assign a unique, five-digit account number to each account and assign an annual interest rateof 3% for the savings account.3. The test program should then display a menu that allows the user to select which optionis to be performed on which account, including the following.a. Make a deposit and specify the amount to a selected or an entered account.b. Make a withdrawal and specify the amount to a selected or an entered account.c. Return the balance of a selected or an entered account.i. For deposit transactions, withdrawal transactions, and balance inquiries, the updatedbalance and any fees charged or interest earned should also be displayed.ii. For the savings account, the number of days since last transaction should be displayed.d. Exit the program.4. Each account operation should display the account number and the account type.Lab QuestionsPlease answer all the lab questions in the text file that is to be turned into the Dropbox. You are notrequired to copy the question text into your document, but all answers should be listed with thequestion number they answer.1. Were any base-class functions called or overloaded in either of the derived classes? If so,list which class and which function, and explain why they were either called or overloaded.2. Were any derived-class functions not explicitly called by the test program? If so, list whichclass and function, and explain why this was done.3. Which access attribute was used for each of the classes derived from the base class? Whywas this access attribute chosen?CLICK HERE TO GET THE SOLUTION !!!!!!!!!!

×