The HTS Bank has been opened with 6 depositors.
You will create a program that will use arrays and methods to answer questions
about the depositors. (e.g. One question is 'what is the total of money
deposited with the bank'.)
| 1. |
To get a SAMPLE program that you will need to add to, look
HERE. |
| 2. |
In the main method, create two arrays, one with the names of the bank depositors and the other
with the depositors' current bank balances. Give at least one depositor a balance of
zero, at least one depositor a negative balance (overdrawn), and the others can have
positive balances.
For example:
| Depositor |
Balance of account |
| Patrick |
75.23 |
| Rachel |
83.50 |
| Aaron |
73.23 |
| Margaret |
-79.01 |
| Mary |
0 |
| Thomas |
-10.34 |
|
| 3. |
Create a keyboard object by adding these lines OUTSIDE of the main method:
private static InputStreamReader input = new InputStreamReader(System.in);
private static BufferedReader keyboard = new BufferedReader(input);
(We do this so that each of the methods can use these
items instead of creating a separate keyboard connection for each method.) |
| 4. |
In the main method, the do...while loop will continue
until the use enters the letter 'Q' to stop.
In do loop, add the code to display the menu of options. It will
give the teller (user) to use any of the following methods
in the exercise. The user will enter a letter:
HTS Bank Menu O Overdrawn accounts P Normal accounts T Total of account balances I Add
interest Q Quit Enter choice-->_
ALSO, add the code to get the user's choice from the keyboard entry. Add
a line of code just after the menu to do this.
|
| 5. |
Create a method that will find and display the names and balances of all
overdrawn depositors. This method is a void method.
 |
| 6. |
Create a method that will find and display the names and balances of all
customers with positive balances. This method is a void method.
 |
| 7. |
Create a method that will find the total of all the account balances. This
method is a double method.
 |
| 8. |
Create a method that will take all of the positive balances and add
interest of 0.5% to the account balance for this month's interest. Total all of the interest paid and
display this at the end. This method is a void method.
 |
Interest of $1.16 added to accounts with a positive
balance |
 |
Note that the total after adding interest has increased
by $1.16 |
|
| 9. |
Update your code to use the keyboard objects by adding this method for keyboard entry:
public static String enterInS (String prompt) throws Exception {
// prompt message received from calling method
// allows user to enter in a string from the keyboard
System.out.print (prompt);
return keyboard.readLine();
} // enterInS
for example:
prompt = "Enter choice-->";
choice = enterInS( prompt ); // get menu choice
|