View the step-by-step solution to:

Overview In this assignment you will write a program that will model a bank with multiple patrons who each have multiple accounts. The user will be

Overview In this assignment you will write a program that will model a bank with multiple patrons who each have multiple accounts. The user will be able to add and remove patrons, as well as have the individual patrons manage their account and money. This will involve interactions between multiple classes which you have defined. When working as a programmer, you are often not writing code from scratch, but are instead adding to an existing project using classes written by others. With this in mind, you will not only be defining two of your own classes, but will also be using a class which will be provided to you.


Note: The requirements listed below are provided in a specific order. Due to the way methods depend on other methods and classes depend on other classes, the requirements are provided in a "bottom-up" approach so that everything is defined before you try and use it. You are welcome to tackle the steps in any order, but you may have issues due to not having methods defined that you need in order to write other ones. This bottom up approach is often how code is written. However, the downside of this approach is that your main method will be the last thing you write. Make sure you make use of your empty main method to test methods and classes you've written before moving too much further ahead. The worst mistake to make would be to write all of this out before trying to test it at all!


Requirements Your program must do the following in order to receive full credit on this assignment. 1. Download the AccountType enum java file, which is attached to the assignment on Blackboard. Add it to your project and ensure it compiles. a. Sometimes an IDE, namely Eclipse, will have issues using files you did not create. If you get several problems (or see a message asking you to "Select Ant build" when you go to run it) create your own file (with the same name!) and copy and paste the contents into it. 2. Download the BankAccount class and add it to your project as well. a. You are not to make any sort of edits to either of these files! 3. Create a new class called BankPatron. 4. Give BankPatron the following private instance variables. a. First Name b. Last Name

c. Salary d. Cash on Hand e. Two BankAccount objects i. It is up to you to determine the needed types for all of these. 1. Look at how BankAccount handles its variables relating to money. You should use the same type it does. 5. Create a default constructor, and then a regular constructor which takes the following parameters. a. First Name b. Last Name c. Salary d. Cash on Hand i. Both constructors will initialize, but not create objects for, the two accounts. 6. Write a get method that returns the full name of the patron. a. Be sure to put a space between the first and last names. 7. Write a get for salary and one for cash on hand. 8. Write a void method that gives the patron a paycheck. a. That is, calculate the amount one paycheck would be and add it to their cash on hand. b. Assume that the salary is yearly, they work all weeks of the year, and are paid bi-weekly. i. As in they are paid every two weeks. 9. Write a method that gets the specified BankAccount. a. It takes an int parameter of 1 or 2 that represents the first or second of the two accounts this patron has. b. If the number is invalid or they do not have that account yet the method should return null. 10.Write a boolean method to make a deposit which takes a double for the amount to deposit and an account to put the money in. a. The provided amount is only added to the account if the patron has at least that much cash on hand. i. That much is then taken from their cash on hand. b. The method should return true if the money was successfully deposited, otherwise it will return false. 11.Write a boolean method which has parameters for an amount and an account to withdraw the money from. a. The method should only return true if the money was successfully withdrawn. i. Use BankAccount's built in withdraw method.

b. The money is added to the patrons cash on hand. 12.Write a boolean method that adds an account to the patron. a. It should have a parameter for rate and one for the account type. b. This account becomes the patron's first account if they don't already have one, or their second if they already have a single account. c. If they already have two accounts the method returns false, otherwise it returns true. 13.Write a boolean method to remove one of the two accounts from this patron. a. Like getAccount, take an int to determine which account to remove. b. Return true only if the account was removed. i. If the account was already null, it would return false. c. Note: This concludes the BankPatron class. 14.Create a new PatronList class which has five private patron instance variables. 15.Create a default constructor which sets all the patrons to null. a. Do not create another constructor. 16.Create a boolean method which takes a BankPatron and adds them as a new patron. a. They can only be added if there is a null instance patron. i. Otherwise the line at the bank is full and this method returns false. 17.Overload the method from the previous step to accept a first and last name, a salary, and cash on hand for a patron and create and add this new patron to the bank. a. Optional: Fun Fact, this method can be only a single line long! 18.Write a method that returns the patron specified in the int parameter. a. 0 represents the first patron, 1 represents Patron 2, and so on. b. Returns null if the parameter is invalid or no patron exists in that slot. 19.Write a method that accepts a patron's full name as a parameter and returns that patron. a. Return null if the patron is not found. 20.Write a boolean method that removes the patron provided in the parameter from the bank. 21.Write a string method to build and return a string of the patron's 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 don't have any accounts only their name should be printed. d. Note: This concludes the PatronList class.

22.In your main file, create a Scanner and a PatronList object that will be usable by all methods in the class. 23.Create a main menu method that will print out the menu, accept input from the user, validate that input, and return the user's choice. The main menu choices are as follows. a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit 24.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 25.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 26.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 don't 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. 27.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. 28.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. 29.If the user chose to have the patron receive a paycheck, call the method you wrote to have the patron get a paycheck. 30.If the user chose to apply the interest rate to the accounts, then calculate the amount of interest for each of the Patron's 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. As is probably obvious, the accounts must exist in order to have interest added to them. 31.If the user chose to make a deposit, have the user specify which account to make a deposit in, using an int 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. 32.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. 33.Finally, write your main method. a. Print a welcome message. b. Call your main menu method to show the menu and get the user's 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. 34.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 patron's information. 35.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. 36.If the user chose to remove a patron, get the patron's name and remove them from the PatronList. a. Take the patron's full name from the user.

b. Use the method you defined in PatronList to get that patron. c. If the patron doesn't exist, print a message that there's no one by that name. 37.If the user chose to do patron specific actions, get the patron's 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 doesn't exist, print an error instead of moving to the patron specific menu. 38.Celebrate!


Example Inputs Below are five example runs of the program with the inputs and outputs. Remember, the graders will be testing your program against these as well as their own, so make sure you test these and come up with your own before submitting your program.


#1


Welcome to the CSE 110 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? Tyler Their last name? Baron Their yearly salary? 100000 // I wish

How much cash do they have on hand? 100 Welcome to the bank, Tyler a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit a Patrons currently at the bank: Tyler Baron a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit e Thank you for coming.


#2


Welcome to the CSE 110 Bank! a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit c Type the full name of the patron you want. Amber Bennett There is no patron by that name. 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?

Mohammed Their last name? Albasha Their yearly salary? 50000 How much cash do they have on hand? 100 Welcome to the bank, Mohammed a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit c Type the full name of the patron you want. Mohammed Albasha Mohammed Albasha left 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 e Thank you for coming.


#3


Welcome to the CSE 110 Bank! 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? Ghaith Their last name? Salman Their yearly salary? 30000 How much cash do they have on hand? 300 Welcome to the bank, Ghaith a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit a Patrons currently at the bank: Ghaith Salman a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit d Type the full name of the patron you want. Ghaith Salman What do you want to do with Ghaith Salman a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu a Which account type did you want?

a. Checking b. Savings c. CD d. Money Market e. IRA a Please input the interest rate. 2 Account successfully added! What do you want to do with Ghaith Salman a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu e Which account (1 or 2) did you want to make a deposit in? 1 How much did you want to deposit? 400 Patron does not have enough cash on hand! What do you want to do with Ghaith Salman a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu e Which account (1 or 2) did you want to make a deposit in? 1 How much did you want to deposit? 50 Deposit made. What do you want to do with Ghaith Salman a. Add New Account

b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu g a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit a Patrons currently at the bank: Ghaith Salman Checking 1001 Balance: 50.0 Interest Rate: 2.0 a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit e Thank you for coming.


#4


Welcome to the CSE 110 Bank! 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? Yiting Their last name? Yao Their yearly salary? 10000

How much cash do they have on hand? 0 Welcome to the bank, Yiting 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? Shokoufeh Their last name? Monjezi Their yearly salary? 25000 How much cash do they have on hand? 20 Welcome to the bank, Shokoufeh a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit d Type the full name of the patron you want. Yiting Yao What do you want to do with Yiting Yao a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu a Which account type did you want? a. Checking b. Savings c. CD

d. Money Market e. IRA c Please input the interest rate. 7 Account successfully added! What do you want to do with Yiting Yao a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu a Which account type did you want? a. Checking b. Savings c. CD d. Money Market e. IRA e Please input the interest rate. 15 Account successfully added! What do you want to do with Yiting Yao a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu g a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit

d Type the full name of the patron you want. Shokoufeh Monjezi What do you want to do with Shokoufeh Monjezi a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu c What do you want to do with Shokoufeh Monjezi a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu a Which account type did you want? a. Checking b. Savings c. CD d. Money Market e. IRA d Please input the interest rate. 3 Account successfully added! What do you want to do with Shokoufeh Monjezi a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu

e Which account (1 or 2) did you want to make a deposit in? 1 How much did you want to deposit? 20 Deposit made. What do you want to do with Shokoufeh Monjezi a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu d What do you want to do with Shokoufeh Monjezi a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu g a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit a Patrons currently at the bank: Yiting Yao CD 1001 Balance: 0.0 Interest Rate: 7.0 IRA 1002 Balance: 0.0 Interest Rate: 15.0 Shokoufeh Monjezi MoneyMarket 1003 Balance: 20.6 Interest Rate: 3.0 a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit

e Thank you for coming.




#5


Welcome to the CSE 110 Bank! 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? Ahmed Their last name? Moussa Their yearly salary? 1231 How much cash do they have on hand? 3432 Welcome to the bank, Ahmed 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? Fatemeh Their last name? Haghighi Their yearly salary? 1231 How much cash do they have on hand? 3432

Welcome to the bank, Fatemeh 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? Ghaith Their last name? Salman Their yearly salary? 1231 How much cash do they have on hand? 3432 Welcome to the bank, Ghaith 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? Amber Their last name? Bennett Their yearly salary? 60000 How much cash do they have on hand? 0 Welcome to the bank, Amber 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?

Void Their last name? Noid Their yearly salary? 0 How much cash do they have on hand? 0 Welcome to the bank, Void 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? Green Their last name? Cheese Their yearly salary? 1 How much cash do they have on hand? 2 The line at the bank is full already! a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit a Patrons currently at the bank: Ahmed Moussa Fatemeh Haghighi Ghaith Salman Amber Bennett Void Noid a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions

e. Quit c Type the full name of the patron you want. Void Noid Void Noid left the bank. 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? Green Their last name? Cheese Their yearly salary? 1 How much cash do they have on hand? 2 Welcome to the bank, Green a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit a Patrons currently at the bank: Ahmed Moussa Fatemeh Haghighi Ghaith Salman Amber Bennett Green Cheese a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit d Type the full name of the patron you want.

Green Cheese What do you want to do with Green Cheese a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu a Which account type did you want? a. Checking b. Savings c. CD d. Money Market e. IRA a Please input the interest rate. 3 Account successfully added! What do you want to do with Green Cheese a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu a Which account type did you want? a. Checking b. Savings c. CD d. Money Market e. IRA c Please input the interest rate. 15 Account successfully added!

What do you want to do with Green Cheese a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu a Which account type did you want? a. Checking b. Savings c. CD d. Money Market e. IRA r Invalid Input e Please input the interest rate. 20 Account could not be added! What do you want to do with Green Cheese a. Add New Account b. Close Account c. Get Paid d. Apply Interest to Accounts e. Make Deposit f. Make a Withdraw g. Return to Main Menu g a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit a Patrons currently at the bank: Ahmed Moussa Fatemeh Haghighi

Ghaith Salman Amber Bennett Green Cheese Checking 1001 Balance: 0.0 Interest Rate: 3.0 CD 1002 Balance: 0.0 Interest Rate: 15.0 a. List Patrons b. Add New Patron c. Remove Patron d. Patron Specific Actions e. Quit e Thank you for coming.


Submission Please submit your Assignment6.java, BankPatron.java, and PatronList.java files to the Assignment 6 link on Blackboard under the Assignments tab. You may submit as many times as you want prior to the due date, in case you later find and fix an error, but only the last one is graded.

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question