Question: For this program you will create two separate Java files within your package, namely AccountHolder and AccountHolderTest . The AccountHolder file must include the following
For this program you will create two separate Java files within your package, namely AccountHolder and AccountHolderTest.
The AccountHolder file must include the following class field members and data methods to allow for transaction processing.
| *Field Name | Field modifier/type |
| annualInterestRate | static / double |
| balance | double |
*assume all class level variables are declared private
| *Method Name | Method (Instance or Static) | Argument | Return Type |
| AccountHolder | Constructor | double | none |
| deposit | Instance | double | void |
| withdrawal | Instance | double | void |
| monthlyInterest | Instance | void | void |
| modifyMonthlyInterest | Static | double | void |
| toString | Instance | void | String |
*assume all methods are declared public
Of course if you would like to add any extra fields or methods in your class feel free to
do so.
Coding detail for this files methods must include the following:
Allow the constructor to accept an argument representing an initial balance for the Account holder. Set your balance member equal to the value passed via the class constructor. Balances cannot start off negative! Include an error message if this is the situation.
Define in your monthlyInterest method body an assignment statement to update the account holders balance to be effected as follows:
balance += balance * (annualInterestRate / 12.0);
Define in your modifyMonthlyInterest method body an assignment statement to update the annualInterestRate amount with some argument value (ex. rateUpdate) that gets passed thru the method as follows:
annualInterestRate = rateUpdate;
Be sure that the updated rate passed thru the methods parameter is a valid rate
that is greater than or equal to 0 and less then or equal to 1.0.
For your deposit & withdrawal methods either have your method body either increase or decrease the holders current balance accordingly.
Some added rules to follow here:
Do not allow the withdraw to decrease the holders balance below $100.
Inform the user of of this if this is the situation.
If a withdrawal allows the account balance to drop below $500, a transaction fee of $50 will be deducted from the current account holders balance.
For your toString method, include the following statement
return String.format("$%.2f", balance);
Fully document your methods. Include comments on what your method is to perform, what parameters (i.e. data types) are to be passed in if any, and what will be returned by the method if anything.
The AccountHolderTest file must include the following transactional detail from your main method, executed in the following order
Prompt the user for an intial account balance (have the balance passed into the AccountHolder constructor).
Prompt the user to enter in a deposit amount.
Prompt the user for a withdrawal amount.
Show an example when a user enters a withdrawal that will drop their balance
below $100.
Allow the interest for the bank to be initially set at 4%.
Display in a columnar format, a report showing interest being added to the users account over a period of 12 months.
Have one column display the month number and one column to show the respected new calculated balance for each particular month. Label your column headings appropriately.
- you can easily allow for any new balances to print merely by passing your an AccountHolder object via your output statement (by doing so you trigger your toString method you defined in your AccountHolder class automatically which returns the accounts current balance).
Update the interest amount once again to 5%.
Display the new balance in the user account given the new interest update.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
