Question
JAVA PROGRAMMING ATM machine: Create a program to simulate an ATM machine. In this program a main menu will be displayed, giving the users the
JAVA PROGRAMMING
ATM machine:
Create a program to simulate an ATM machine. In this program a main menu will be displayed, giving the users the following options:
Check balance
Withdraw
Deposit
Exit
Based on the users choice your program should display the information. Note: A data file data.txt has been provided.
Here are the classes that needs to be implement: 1. Create a class called Account with the following UML diagram. Compile your cod
Account |
-int id //default 0 -String name //default -double balance // default 0 -boolean active //set to false by default |
+Account() //sets all the instance variables to the default values +Account (int id, double balance, String name)//creates an account with the given info +getId(): id +getBalance(): balance// returns the balance +getName(): name +setId(int id): void +setName(String name): void +setActive(boolean b): void +setBalance(double b): void +activateAccount(): void // sets the active variable to true +deactivateAccount(): void //set the active variable to false +close(): void // this method closes the account by withdrawing all the money, and deactivates the account +deposit(double amount): void//deposit the given amount to the balance +withdraw(double amount): void//withdraw the amount from the balance, check to see if amount < balance +equals(Account a): boolean // two accounts are equal if their ids are equal +toString(): String // create a string representation that is easy to read and has the id, name, balance and whether or not it is active. |
2. Create a driver class with the following methods: a. Main method:
i. call the method run b. run method:
Declare an array with ten elements of Account data type
Call the method populate to populate your array
Declare all the needed variables
In this program as long as the user has more transactions you provide the
menu. Once the first user is done then, prompt the user to get the id for the
next customer. Therefore two while loops are needed: while (more customers)
and the other one should be while (more transactions). c. Create a method called populate: this method populate the arrays of the account by
reading the info from the text file that you just created.
Create a method called display: This method display all the options that appears on the
screen of an ATM machine.
Create a method called searchId(int id, Account[] accounts): this method searches the
array to find the given id, returns the index of the id if the id is found, else returns -1
Create a method called description that describes what this program is doing
Create a method called withdraw(int index, Account[] accounts):
Prompt the user to get the withdraw amount
Call the proper method from the Account class on the object
Display any needed info
Create a method called deposit(int index, Account[] accounts)
Prompts the user for the deposit amount
Call the correct method from the Account class
Create a method called checkBalance(int index, Account[] accounts): this method displays the balance on the account
i. Call the proper method from the Account class to display the balance
Create a method called getChoice(Scanner kb), this method prompts the user to enter
the choice. Valid choices are 1-4. As long as the user is entering any other number, you
need to prompt the user for the proper choice
Write a method called getFileName(Scanner kb), as long as the file does not exist, you
need to prompt the user for a new file name.
Write a method called listCustomers(Account[] accounts): this method list all the
customers for this bank.
Write a method getValidInput(Scanner kb): this method prompts the user for a valid
input. As long as the input is not valid keep prompting the user. The users input must
be double and also greater than 0.
Add other features to use the unused methods from the Account class.
Earn 10 points extra credit by adding more options to the menu and adding more
methods in the Account class.
Data Text
Alex Lambardi 123456 12000
Mary Busta 345678 1500
Tia Yang 907856 12350
Alex Bogdan 452367 560
Joe William 122143 1000
Jack zhang 985634 20000
Rose Bever 887766 200
Josh Li 455548 12000
Nik Patten 128956 54000
Jack Liang 450089 2300
Sample Output:
//you must output the description here
Enter the file name: sdfsdf
File not found. Enter a valid file name: sddsf
File not found. Enter a valid file name: data.txt
Enter your ID: 3434
Enter your ID: eert
Invalid ID. Enter your ID: ddf
Invalid ID. Enter your ID: 3456
Enter your ID: 123456
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 1
here is your account info
Alex Lambardi
ID: 123456
Balance:12000.0
Active account
---------------
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 2
Enter a positive amont: dfdf
Enter a valid amount: -5678
Enter a positive amont: 100
100 has been withdrawn from your account
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 1
here is your account info
Alex Lambardi
ID: 123456
Balance:11900.0
Active account
---------------
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 3
Enter a positive amont: tytyu
Enter a valid amount: fgh
Enter a valid amount: -6789
Enter a positive amont: 340
340 has been deposited to your account
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 1
here is your account info
Alex Lambardi
ID: 123456
Balance:12240.0
Active account
---------------
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 8
Wrong choice, try again:
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 9
Wrong choice, try again:
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 4
Is there any one else in the line? yes
Enter your ID: dfdf
Invalid ID. Enter your ID: 345678
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 1
here is your account info
Mary Busta
ID: 345678
Balance:1500.0
Active account
---------------
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 2
Enter a positive amont: 2000
The amount is too large, transaction ignored
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 100
Wrong choice, try again:
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 3
Enter a positive amont: -5678
Enter a positive amont: ffgf
Enter a valid amount: dfg
Enter a valid amount: 1200
1200 has been deposited to your account
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 1
here is your account info
Mary Busta
ID: 345678
Balance:2700.0
Active account
---------------
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 89
Wrong choice, try again:
Main menu
1: check balance
2: withdraw
3: deposit
4: exit
Enter a choice: 4
Is there any one else in the line? no
Have a good day
----jGRASP: operation complete.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started