Question
Chapter 8: Exercises #11, #12, and #13, page 568 30 points You are to incorporate all requirements of the three exercises into the basic class
Chapter 8: Exercises #11, #12, and #13, page 568 30 points You are to incorporate all requirements of the three exercises into the basic class definition provided in the Exercise #11 description. In addition, you must check the values of deposit, withdrawal, and transfer amounts to ensure they are greater than 0. For two of the three methods, deposit and withdraw, the methods are to return a boolean value to indicate if the transaction was completed. For method transfer, the method is to RETurn the allowed amount transferred, refer to Exercise #13 for details for a partial transfer. In addition to the specified class methods, provide a method name() that returns a String reference to the objects account name. To start this project, create an Eclipse project and copy the two supplied source code files, Project9_BankAccount.java and BankAccount.java into the projects src folder. File BankAccount.java has the class definition shown in the text as your starting point; note that methods deposit and withdraw are incomplete! You must define all required methods in this file. You should not modify the Project9_BankAccount.java file as it provides a means to test your code. I will utilize this same test program to verify the functionality of the BankAccount class source code file you submit. Your code must work as shown with my test program! A sample Console output from this program is shown below. Code method toString() to produce the output shown for the class objects in the following Sample Console Output. Comment your code to include: (1) File and method header descriptions (Use the supplied file Project9_BankAccount.java to start your project, and (2) General comments throughout the source code. Project Submission: Using the Canvas Assignment upload feature, submit a compressed file (*.zip) for your project submission (format: LastnameProject9.zip) that includes the following files: Source Code file (BankAccount.java). You do not need to include any additional project files. A short Word summary of your work. Use one of the supplied Project Summary documents to answer the required questions. Sample Console Output: Project #8 Solution Chapter 8, Exercise #11, page 568 Example #1: Account object instantiated with name only Beginning account: John Doe, $0.00, Total fees: $0.00 Depositing: $51.75 John Doe, $51.75, Total fees: $0.00 Withdrawing: $7.96 John Doe, $43.79, Total fees: $0.00 Depositing: $14.78 John Doe, $58.57, Total fees: $0.00 Depositing: $-4.59 Unable to deposit $-4.59 Withdrawing: $45.79 John Doe, $12.78, Total fees: $0.00 Withdrawing: $-3.57 Unable to withdraw $-3.57 Withdrawing: $12.78 John Doe, $0.00, Total fees: $0.00 Withdrawing: $0.01 Unable to withdraw $0.01 Example #2: Account object instantiated with name and beginning balance: $23.67 Beginning account: Sarah Jones, $23.67, Total fees: $0.00 Depositing: $51.75 Sarah Jones, $75.42, Total fees: $0.00 Withdrawing: $7.96 Sarah Jones, $67.46, Total fees: $0.00 Example #3: Account object instantiated with name, beginning balance: $34.57, and transaction fee: $2.50 Beginning account: Samuel Johnson, $34.57, Total fees: $0.00 Depositing: $51.75 Samuel Johnson, $86.32, Total fees: $0.00 Withdrawing: $7.96 Samuel Johnson, $75.86, Total fees: $2.50 Withdrawing: $75.86 Unable to withdraw $75.86 Example #4: Transfers between two accounts myAccount: Sarah Jones, $67.46, Total fees: $0.00 yourAccount: Samuel Johnson, $75.86, Total fees: $2.50 Transfering $41.38 from Sarah Jones's account to Samuel Johnson's account Source Account: Sarah Jones, $21.08, Total fees: $5.00 Amount Transferred: 41.38 Destination Account: Samuel Johnson, $117.24, Total fees: $2.50 Transfering $-8.79 from Sarah Jones's account to Samuel Johnson's account Unable to transfer $-8.79 Transfering $78.67 from Samuel Johnson's account to Sarah Jones's account Source Account: Samuel Johnson, $33.57, Total fees: $7.50 Amount Transferred: 78.67 Destination Account: Sarah Jones, $99.75, Total fees: $5.00 Transfering $94.74 from Sarah Jones's account to Samuel Johnson's account Source Account: Sarah Jones, $0.01, Total fees: $10.00 Amount Transferred: 94.74 Destination Account: Samuel Johnson, $128.31, Total fees: $7.50 Transfering $0.01 from Sarah Jones's account to Samuel Johnson's account Unable to transfer $0.01 Transfering $150.0 from Samuel Johnson's account to Sarah Jones's account Source Account: Samuel Johnson, $0.00, Total fees: $12.50 Amount Transferred: 123.31 Destination Account: Sarah Jones, $123.32, Total fees: $10.00 1. You must design your "BankAccount" class such that it will satisfy the requirements stated in the three text problems. The supplied Client program will invoke the required class, non-static methods described in the text and in the Project Description document (Note the additional, required method, "name()". 2. The supplied Client program creates 3 different "BankAccount" objects. You should notice that each takes different number of arguments. Therefore, you will need to supply at least 3 Constructors for the class. You are to make sure that proper values are passed to the Constructors you define, i.e. the starting balance and transaction fee must be greater than 0.0. Also note that unless supplied in a Constructor, the transaction fee is set to the specified "default" value....hint a Class constant value. 3. For Class method "deposit" you must enforce the invariant condition that a deposit amount must be greater than 0.0. The same goes for a withdrawal and transfer amount supplied to methods "withdraw" and "transfer". 4. For a "withdraw", the transaction can be completed iff (if and only if) the specified withdraw amount PLUS the transaction fee is >= the current balance. 5. You are to keep an accumulated total of all fees charged to the account; i.e. update this amount each time the "withdraw" and "transfer" methods are called. 6. For a transfer, there is fixed, constant fee of $5.00. Note that this is a different fee than the transaction fee that applies to a withdrawal. The transfer can only occur if the current balance of the invoking "BankAccount" object exceeds $5.00. If the account balance exceeds $5.00 but is less than the requested transfer amount plus the $5.00 fee, a partial transfer can occur that leaves the invoking object's balance as exactly $0.00. Only the allowed transfer amount is "deposit"ed to the target account, the "BankAccount" object reference passed to the "transfer" method. 7. You will need to provide an overridden "toString()" method as specified in Exercise #12. In addition to the format specified in the exercise, you are to include the total accumulated fees charged, see my sample output. 8. You are free to use class private "helper" method(s) to implement your method designs. A good example would be methods(s) to enforce the invariant conditions.
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