ATM Machine
February 26, 2019
Today’s exercise asks you to simulate an ATM machine:
- Prompt for userid and password. If userid and password are not in the database, reprompt.
- Display balance.
- Present a menu asking to deposit, withdraw or exit. If user selects withdraw or deposit, perform the indicated transaction and goto Step 2. Deny withdrawals that would overdraw the account.
- Exit the program.
Your task is to write a program to simulate an ATM machine. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.
Your suggested solution has a large chunk missing (comparing with the ideone version, looks like a section in angle brackets has disappeared).
@matthew: Thanks. I think it’s fixed now. On the other hand, last night when I edited the exercise it looked right, too. WordPress has been playing with their editor lately, improving it. Things may change tomorrow.
Here’s a solution in Python.
Example:
Scheme version for completeness:
Example output: