CSE 101 Programming Assignment 2 Page 1 of 4
Due:
Sunday, 21-November-2021 by 23:59
Deliverables:
The following Java file should be submitted to MS Teams by the due date and time
specified above. Submissions received after the deadline will be subject to the late
policy described in the syllabus.
o ATM_{StudentNumber}.java
Specifications:
Overview: You will continue your program this week to maintain the account balance for a
user of an ATM. Do not forget your headers with @author and @version information. This
program will be expanded in future weeks, so be sure you understand the concepts covered
in this program.
Requirements: Write a program that will simulate the user interface for an ATM. It will
allow the user to select one of four (4) options:
1. Display Balance
a. Should display to the user the amount remaining in his/her account.
2. Deposit Money
a. Adds to the balance the amount deposited
b. Should verify the amount is valid (as described below)
3. Withdraw Money
a. Removes the amount from the balance
b. Should verify the amount is valid (as described below)
4. Exit
To facilitate the execution of this program, you will write (at minimum) the following
methods:
1. main()
a. A method to run the atm program
b. It will ask the user for three parameters representing the name, surname,
and starting balance for the customer.
c. It will then run according to the description until the user types “0” or an
invalid value (display a message before exiting for invalid values)
d. Returns None
2. isDepositValid(amount)
a. A method to verify the deposit is valid
b. Takes one double type parameter for the amount entered
c. Returns a boolean
i. True if amount is positive
ii. False for all other values
CSE 101|Fall 2021 1
CSE 101 Programming Assignment 2 Page 2 of 4
3. isWithdrawalValid(balance, amount)
a. A method to verify the withdrawal is valid
b. Takes two double type parameters for the current balance and the
amount to be withdrawn
c. Returns a boolean
i. True if amount is positive and less than or equal to balance
ii. False for all other values
4. moneyGiven(amount)
a. A method to determine the type of bills and coins to be given
b. Takes one parameter for the amount to be given
c. Returns a String containing the number of each type of bill in the format
of “# - Type” (i.e. “2 – 20”, “3 – 1”), each on a separate line.
i. The values tested will be standard TL types (200, 100, 50, 20, 10, 5,
1, 0.50, 0.25, 0.10, 0.05, 0.01)
5. Any other methods you feel helpful can be implemented, however, these will be
the only methods tested.
Design:
When validDeposit is called with the given parameters, the following values should be returned:
When validWithdrawal is called with the given parameters, the following values should be
returned:
When the method moneyGiven is called with the following values, the returned String
should be one of these shown.
CSE 101|Fall 2021 2
CSE 101 Programming Assignment 2 Page 3 of 4
When run, your program should ask the user for his/her name, surname and beginning
balance, then greet the user and process their requests. An example is given below (note
that the program changes the surname to all uppercase letters):
If the user enters invalid values, the program should display a message saying that the
value is not acceptable. If an invalid starting balance is entered, the program should
continue requesting a balance until a valid value is given. If an invalid deposit or
withdrawal amount is entered, the program should return to the main menu. If an invalid
menu option is entered, the program should display a message and exit. Examples
shown:
CSE 101|Fall 2021 3
CSE 101 Programming Assignment 2 Page 4 of 4
Code: Create variables for the various values entered by the user and assign it using the
Scanner object. As a user enters valid values for depositing and withdrawing money,
update the balance variable accordingly.
Test: You are responsible for testing your program. It is important to not rely solely on
the examples presented in this Project description.
Grading:
MS Teams Submission: You can submit multiple times, however, we will only grade the last
version that you submitted.
NOTE: If you use System.exit() in your code, you will automatically receive 0 points for this
assignment.
Quiz: There will be a quiz based on this assignment given on 26-November at 08:40 on MS
Teams and in lab. The result of this quiz will be used to determine your grade on this
assignment. Note: if you do not submit the quiz, your score on this assignment will be 0.
CSE 101|Fall 2021 4