Question: 22. Write a string method to build and return a string of the patrons info which can be printed later. a. It should print their

22. Write a string method to build and return a string of the patrons info which can be printed later. a. It should print their full name first. b. It then prints their first account info. i. This takes the form: (accountType) (accountNumber) Balance: (balance) Interest Rate: (rate). ii. See example outputs. iii. This is assuming they have an account at all. c. Then print their second account in the same format, if they have one. i. If they dont have any accounts only their name should be printed. d. Note: This concludes the PatronList class.

23. In your main file, create a Scanner and a PatronList object that will be useable by all methods in the class.

24. Create a main menu method that will print out the menu, accept input from the user, validate that input, and return the users choice. The main menu choices are as follows. a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit

25. Create a patron menu method that will work like the main menu, but prints out the menu for actions for a specific patron when the user chooses option d in the main menu. a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make Withdraw g. Return to Main Menu

26. Create a third menu method that prompts the user for which account type they want. This will be used when adding new accounts to a patron. a. Checking b. Savings c. CD d. Money Market e. IRA

27. Write a void method that handles actions for the patron specific menu. a. This should take a patron object as a parameter and apply all actions to that patron. b. Call the method to print the patron specific menu and store the user input. c. Create a loop that will run until the user chooses to return to the main menu. i. As always dont forget to reprint the menu and take a new input at the bottom of the loop. d. The actions to take in the loop are described in the following steps.

28. If the user chose to add a new account, determine what account type the user wants, accept a double as the interest rate from the user and then use that information to add a new account to the patron. a. Print out a message depending on whether adding the account succeeded or failed.

29. If the user chose to remove an account, accept an int from the user representing which account to remove and remove that from the patron object. a. Again, print a success or failure message.

30. If the user chose to have the patron receive a paycheck, call the method you wrote to have the patron get a paycheck.

31. If the user chose to apply the interest rate to the accounts, then calculate the amount of interest for each of the Patrons accounts and add it to the balance of that account. a. For example, if the first account had $100 in it and had a 2% interest rate, it would have $102 in it afterwards. b. Note that the rates are different for the two accounts and each should only get its own rate amount added to it. c. Obviously, the accounts must exist in order to have interest added to them.

32. If the user chose to make a deposit, have the user specify which account to make a deposit in, using an in value again, then accept the amount to deposit, and finally have the patron make that deposit. a. Print a success or failure message. b. If the specified account does not exist, print an error message instead.

33. If the user chose to make a withdrawal, follow the same procedure as making a deposit, but withdraw the money instead. a. Again print the appropriate messages.

34. Finally, write your main method. a. Print a welcome message. b. Call your main menu method to show the menu and get the users choice. c. Have a loop that will run until the user chooses to exit. i. The steps to do in the loop are specified in the next steps. d. Print a goodbye message after the loop before the program ends.

35. If the user chose to list the patrons, print out the information for each patron in the PatronList. a. If there are none, print None. b. Use the method you defined in PatronList to get a string of each patrons information.

36. If the user chose to add a new patron, get the appropriate information and add the patron to the bank. a. You will need the first and last name of the patron, their salary, and how much cash they have on hand. b. Print a message welcoming them to the bank if they were successfully added to the PatronList, otherwise print a message that the bank line is full already.

37. If the user chose to remove a patron, get the patrons name and remove them from the PatronList. a. Take the patrons full name from the user. b. Use the method you defined in PatronList to get that patron. c. If the patron doesnt exist, print a message that theres no one by that name.

38. If the user choise to do patron specific actions, get the patrons name and pass that patron to the patron specific method you created previously. a. Again, get their full name and use the method you already wrote to get that patron. b. If the patron doesnt exist, print an error instead of moving to the patron specific menu.

So far I have:

import java.util.*;

public class BankPatron

{

private String firstName;

private String lastName;

private double salary;

private double cashOnHand;

private BankAccount accounts[];

public static void main (String[] args)

{

Scanner scan = new Scanner(System.in);

}

public BankPatron() {

firstName = "Diana";

lastName = "Vera";

salary = 0;

cashOnHand = 0;

}

public BankPatron(String firstName, String lastName, double salary, double cashOnHand) {

firstName = firstName;

lastName = lastName;

salary = salary;

cashOnHand = cashOnHand;

}

public String getFullName()

{

return firstName + " " + lastName;

}

public double getSalary()

{

return salary;

}

public double getCashOnHand()

{

return cashOnHand;

}

public void givePayCheque()

{

//...

}

public BankAccount getBankAccount(int index)

{

if(index >= 1 && index <= 2)

{

return accounts[index];

}

return null;

}

public boolean deposit(double amount, int index)

{

if(amount <= cashOnHand)

{

accounts[index].deposit(amount);

cashOnHand -= amount;

return true;

}

return false;

}

public boolean withdraw(double amount, int index)

{

if(accounts[index].withdraw(amount))

{

cashOnHand += amount;

return true;

}

return false;

}

}

But my program needs to print something like this:

Welcome to the Bank!

a. List Patrons b. Add New Patron c. Remove Patron

d. Patron Specific Actions e. Quit a Patrons currently at the bank: None

a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit b What is the first name of the new patron? Sam Their last name?

Lee Their yearly salary? 100000 // I wish How much cash do they have on hand? 100 Welcome to the bank, Sam a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit a Patrons currently at the bank: Sam Lee a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit e Thank you for coming.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!