In this assignment you'll be implementing a simple ATM.
You'll be writing two classes:
The Account class keeps track of customer information like their name and bank balance, and can perform transactions like depositing or withdrawing money from the account. The Account class should have the following fields (attributes):
The Account class should have the following methods:
This class implements a console user interface for the ATM. It should do the following:
1. In the main method, create two bank accounts (two Account objects). The first account should be created with ID 101 and your name. The second account should be created with ID 102 and the name of your favorite movie actor.
2. Set the balance for account ID 101 to $50 and account ID 102 to $1000. Set the annual interest rate for both accounts to 5%.
3. Prompt the user to enter an ID. This is the ID of the account to use in the next step. The only valid answers here will be the IDs used in step 1. If the ID is entered incorrectly then print an error message and ask for the ID again.
4. In another method of the ATM class, display the main menu. This method is called from main and should be named 'menu'. The menu method allows you to perform transactions like deposit, withdraw, and check account info. You will pass one of the two account objects to the menu method (pass the account the user selected). You should declare the menu method like this:
public void menu(Account acct)
Notice that this method accepts one parameter, the account object the user selected by entering an ID number in step 3.
Study the sample run below to see what the menu might look like and what each function should do. The "Account info" function should display the customer name, the customer's bank balance, and the monthly interest amount.
Enter an account ID: 102
Main Menu
1: Account info
2: Withdraw
3: Deposit
4: Exit
Please choose what you’d like to do: 1
Customer: Clint Eastwood
Account Balance: $1000.00
Monthly interest earned: $4.17
Main Menu
1: Account info
2: Withdraw
3: Deposit
4: Exit
Please choose what you’d like to do: 3
Enter the amount to deposit: 3.50
Main Menu
1: Account info
2: Withdraw
3: Deposit
4: Exit
Please choose what you’d like to do: 2
Enter the amount to withdraw: 10
Main Menu
1: Account info
2: Withdraw
3: Deposit
4: Exit
Please choose what you’d like to do: 1
Customer: Clint Eastwood
Account Balance: $993.50
Monthly interest earned: $4.14
Main Menu
1: Account info
2: Withdraw
3: Deposit
4: Exit
Please choose what you’d like to do: 4
Enter an account ID:
The menu method should display the main menu again and ask for another choice after every transaction (1, 2, 3), except exit (4). When exit is selected it should return to the main method, which prompts for another account ID. Thus once the system starts it will not stop (this is like a real ATM where a regular user can't stop the system).
For full marks do not use the keyword 'static' except for the main method declaration and for constant (final) fields. Youll need to create an object of the ATM class in the main method so you can call the menu method.
Add a field to the account class, as follows:
dateCreated - A field of type Date which stores the date/time the account was created (Date is in the java.util package, see Java documentation)
You should write a getter for the dateCreated field, but not a setter. When an object of type Date is created using the default constructor it gets initialized to the current time, you can use this to automatically initialize the field.
Update your ATM "account info" menu option so that it also prints out the date/time the account was created.