Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python PROBLEM STATEMENT: We want to simulate a simple ATM machine. An account holder should be able to sign in and see a menu of

Python PROBLEM STATEMENT: We want to simulate a simple ATM machine. An account holder should be able to sign in and see a menu of transactions: get balance, withdraw, deposit, or quit. The ATM should properly and regularly communicate with the user. The ATM should get information on existing users and accounts from a file. An accounts.txt file is posted together with this assignment. You should look carefully at the structure of each line of the file, which contains a 4 digit secret code, first and last name of users, and the current balance. REQUIREMENTS: 1. At the start, your ATM will read the account.txt file and properly store the information. Make sure the application does not raise any un-handled IOError when trying to access accounts.txt. If the file is not found, simply notify the user that the system is experiencing problems, and then quit. 2. The ATM should prompt the user to enter her 4 digits secret code and should then greet the user by name if the user is an account holder and present the 4 menu options (balance, withdraw, deposit, quit), or print a message that indicates that the 4 digit code entered does not correspond to a current client and quit. Under no circumstance the execution should be interrupted because of an Error. 3. As long as the user does not choose Quit, after completing each transaction she should be reprompted with the 4 menu options, without having to re-enter the secret code 4. When the user chooses deposit: a. Ask for the amount to be deposited b. Ensure that in case of incorrect input the user is re-prompted by proper exception handling (say the user enters a generic string instead of a numeric value, or presses the enter key without entering anything) until a proper input is provided. c. Update the balance d. Communicate success of the operation 5. When the user chooses withdraw: a. Ask for the amount to be withdrawn b. Ensure that in case of incorrect input the user is re-prompted (say the user enters a generic string instead of a numeric value) until a proper input is provided. c. Update the balance if there are enough funds d. Gives the user repeated opportunities to enter a different amount if there are not enough funds available and update the balance once an acceptable amount is entered e. Communicate the success of the operation 6. When the user chooses balance: a. Show the current balance 7. When the user chooses quit: a. The application will rewrite all data (4-digit pin, first name, last name, updated balance) on the accounts.txt file and then quit. Try to structure your code in a modular and encapsulated fashion, as much as possible, by creating separate functions dedicated to separate operations. If a variable (say balance) corresponding to an immutable object is defined within the main code and needs to be reassigned (say balance += amount) inside a function (say deposit), in order to maintain proper encapsulation, you will need to pass the variable as a parameter to the function and return it at the end. Alternatively you can declare such variable global inside the function which will allow the function to modify the variable defined in the main namespace.

accounts.txt:

8073 Nicholas Nickleby 23750.0 2245 Paul Newman 1235456.5 3381 Tom Sawyer 12.0 2813 Nate Silver 125.0 7643 Nancy Reagan 2132106.12 9967 Tony Manero 10.05 1234 Mary Zimmerman 23000.0 6345 Alfonso Chavez 98745.35 2315 Terry Kulakowski 234.0 4455 Yu Chen 78000.0 7465 Natasha Andropova 3579.83 7395 Ankit Patel 33579.0 9900 Bill Gates 2345000000 4466 Kay Winthrop 356.0 3221 Carlos Mencia 235120.05

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago