Question: Java Beginners Programming Class * Remember to leave comments on what program does what Consider a bank ATM. You put in your bank card, key
Java Beginners Programming Class
* Remember to leave comments on what program does what
Consider a bank ATM. You put in your bank card, key in your PIN and then you have a variety of actions like checking your account balance, making a withdrawal and making a deposit. Today you will write a program to emulate some of these functions. Unfortunately no real cash will be dispensed!
Spend some time thinking about how you will organize your sub-routines/methods and note how they must be re-used throughout the program.
Here are some assumptions:
There is only ONE bank account in the world. It has an initial balance of $100.00
The correct PIN for this account is: 1234
Starting your program (running the main method) is like inserting your card. Once you run it, here are the problems it should solve:
Part 1 - Prompt user to enter the PIN
Ask the user to enter their PIN. Give them three (3) tries. If it is incorrect then print Please try again, you have X tries remaining and ask user to retry. Substitute the X with 2 or 1 based on which try they are on. If user has three (3) incorrect tries then print Your account is locked and exit the program. If the correct PIN is entered at any time then proceed to Part 2.
Part 2 - Show Main Menu
Print out the following menu.
Balance Inquiry
Withdraw Cash
Deposit Cash
Exit
At this time let the user enter a number and based on the choice perform the action (as described below). Assume a correct answer will always be given so you can skip error checking in this part.
Part 3 Balance Inquiry
Print Your current account balance is $xx.xx (use appropriate value and round upto two places of decimal)
After printing the balance, show the prompt Hit Enter. Once they press enter print the main menu again (same as Part 2).
Part 4 Withdraw Cash
Print Enter amount to withdraw $ and let the user enter a number. Subtract that number from the current balance. The following rules to the withdrawal:
It must be a multiple of 20. Eg: 20, 40, 60, 80 etc.
It cannot be less than 20 and cannot exceed the current balance. For example if balance is $100 you cannot withdraw $120 (our ATM only has $20 bills)
It cannot be a fraction (our ATM cannot dispense coins)
In all error cases print Not Allowed and show the same prompt again (Part 4)
If successful, assume money was dispensed and print the current balance (exactly as in Part 3) and then prompt the user to Hit Enter and go back to main menu (same as Part 2)
Part 5 Deposit Cash
Print Enter amount to deposit $ and let the user enter a number. Add that number to the current balance. The following rules apply:
Minimum amount is $1 and maximum is $100
Our ATM accepts coins as well so fractional values are ok (eg: deposit $20.25 is ok)
Assume actual money was deposited and print the new balance (exactly as in Part 3) and then prompt the user to Hit Enter and go back to main menu (same as Part 2)
Part 6 Exit
If user picked this option then print Please take your card and end the program.
*Note to your assignment -/do not use arrays, and work on your indents and oragnization.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
