Develop a program called ATM. It allows customers to deposit and withdraw in these denominations: 20, 10, 5, and 1 dollar bills.
Customer inputs the number of currency notes in each denomination
- If any input values are negative, print "Incorrect deposit amount".
- If all the input values are zero, print "Deposit amount cannot be zero".
- If the input values are valid, increment the balances of corresponding dollar bills and print the available new balances in each denomination and the total balance.
Customer input the amount to withdraw. ATM dispenses the 20, 10, 5, and 1 dollar bills as needed.
- If the input amount is zero, negative, or over the current balance, print "Incorrect or insufficient funds".
- If the input amount is in valid range, print the number of current notes dispensed in each denomination. Use the available higher denomination first. Also, print the available new balances in each denomination and the total balance.
For example,
Balance: 20s=0, 10s=8, 5s=20, 1s=0, Total=180
Balance: 20s=3, 10s=8, 5s=38, 1s=4, Total=334
Dispensed: 20s=3, 10s=1, 5s=1 Balance: 20s=0, 10s=7, 5s=37, 1s=4, Total=259
Dispensed: 10s=7, 5s=10, 1s=2 Balance: 20s=0, 10s=0, 5s=27, 1s=2, Total=137
Output: "Incorrect or insufficient funds"
Output: "Incorrect or insufficient funds"
Output: "Incorrect or insufficient funds"
Tips: This program should be expandable to support 50s and 100s in future. Please allow the program to support any denominations with little or no code change.
public class ATM {
public void deposit(...) {
}
public void withdraw(...) {
}
}