Reference no: EM132366222
Assignment
Objectives
This assignment requires you to create a program in Java programming language to simulate a bank ATM.
Upon completion of this assignment, you should be able to create object-oriented programs using classes and objects with methods that use proper data types, variables, arithmetic expressions, simple control flow and interaction with users through simple input and output devices.
General Requirements
• You should create your programs with good programming style and form using proper blank spaces, indentation and braces to make your code easy to read and understand;
• You should create identifiers with sensible names;
• You should make comments to describe your code segments where they are necessary for readers to understand what your code intends to achieve.
• Logical structures and statements are properly used for specific purposes.
• Other requirements as stated in Submission section.
• All your program files should include the following header. Submissions without this header will not be marked and the zero mark will be given.
/**
* CSIT111/CSIT811 Assignment 1
*
* Student name:
* Student user ID:
* Student number:
*/
• You should only use Java language structures covered up to Week 5.
Tasks
You will create a Java program called ATMApp.java. This program will make use of a class called ATM.
Task 1: ATMApp program
You create your ATMApp program according to the following requirements.
1. The ATMApp program will read a saved PIN and account balances for Savings and Checking accounts; The file stored the values is provided as balances.txt. The file name will be provided to the program as command line argument.
2. The program then will ask for PIN. The entered PIN will be compared with the saved PIN. If the entered PIN is not the same as the saved PIN, the program will continue asking for correct PIN.
The saved PIN is a hashed value from a 6-digit PIN. The hash function used to create the saved PIN is defined as
hash(x) = (x * A) mod (232)
where A = 2654435761.
3. Once the PIN is verified, the program will show the main menu of the ATM machine.
Task 2: ATM class
The ATM class models an ATM machine and supports your ATMApp program. You will create the ATM class according to the following requirements.
1. The class will have fields to store balances of both Savings and Checking accounts and the selected account.
The ATM will provide the following methods:
2. A constructor that receives balances for both accounts.
3. selectAccount method will prompt the customer to select an account from a list of Savings and Checking accounts. This method will display the following screen prompt and take customer input.
1 - Savings
2 - Checkings Which account:
4. showMainMenu method will show the main menu of the ATM machine for transactions. The customer can select what to do from a list. The method will display the following screen prompt and take customer input.
1 - Inquire Balance
2 - Withdraw
3 - Deposit
4 - Other account
0 - Quit
5. deposit method will deposit an amount entered by the customer and updates and display the updated balance.
6. withdraw method will withdraw an amount entered by the customer and updates and display the updated balance if the amount to withdraw is less than the current balance. Otherwise, it will show a message "Insufficient balance".
7. displayBalance method will display the current balance of the account. The monetary value will be displayed as dollars and cents.
You need to observe the sample screenshot in the Testing section to understand more how the program will interact with the customer and implement your program to realise it.
Testing
The saved PIN in the provided balances.txt file is the hashed value of 2522.
(User input is in red colour, results in blue colour and prompt lines in black colour. Colours in this paper are for readability only. Your program does not need to print in color.)
java ATMApp balances.txt
Please enter your PIN: 2000
Please enter your correct PIN: 2522
1 - Savings
2 - Checking Which account: 1
1 - Inquire Balance
2 - Withdraw
3 - Deposit
4 - Other account
0 - Quit 1
The current balance is $10000.00
1 - Inquire Balance
2 - Withdraw
3 - Deposit
4 - Other account
0 - Quit 2
Enter the amount to withdraw: 500.50 The current balance is $9499.50
1 - Inquire Balance
2 - Withdraw
3 - Deposit
4 - Other account
0 - Quit 3
Enter the amount to deposit: 1500 The current balance is $10999.50
1 - Inquire Balance
2 - Withdraw
3 - Deposit
4 - Other account
0 - Quit 4
1 - Savings
2 - Checking Which account: 2
1 - Inquire Balance
2 - Withdraw
3 - Deposit
4 - Other account
0 - Quit 1
The current balance is $20000.00
1 - Inquire Balance
2 - Withdraw
3 - Deposit
4 - Other account
0 - Quit 2
Enter the amount to withdraw: 15000 The current balance is $5000.00
1 - Inquire Balance
2 - Withdraw
3 - Deposit
4 - Other account
0 - Quit 2
Enter the amount to withdraw: 10000 Insufficient balance.
1 - Inquire Balance
2 - Withdraw
3 - Deposit
4 - Other account
0 - Quit 3
Enter the amount to deposit: 1000 The current balance is $6000.00
1 - Inquire Balance
2 - Withdraw
3 - Deposit
4 - Other account
0 - Quit 0
Your program may be tested with different balances, PIN and user input.