Question

In: Computer Science

Due Sept 25th at 11:55 pm You are going to make an advanced ATM program When...

Due Sept 25th at 11:55 pm

You are going to make an advanced ATM program

When you run the program, it will ask you if you want to:

  1. Either log in or make a new user

  2. Exit

Once I have logged in, I will have 3 balances, credit, checking, and savings. From here it will ask which account to use.

Once the account is picked they can deposit, withdraw, check balance, or log out.

Each time the user performs one of these actions, it will loop back and ask them for another action, until the Logout

(Hint: Make sure they can’t withdraw too much money)

Submission name: Advanced_ATM.py

(Capitalization matters for this, any non .py files will be -20 points)

Submit the file here by the assigned date, every day late will be 15 points off

Solutions

Expert Solution

The following code performs the tasks specified in the question:

#list of users
users = []
currUser = None

#userclass
class User:
def __init__(self,uname,pwd): #constructor
self.username = uname
self.password = pwd
self.accounts = {"credit" : 0, "checking" : 0, "savings" : 0}
def auth(self,uname,pwd): #authentication function
return self.username == uname and self.password == pwd

def login(uname,pwd): #method for login
for user in users:
if(user.auth(uname,pwd)):
return (True, user)
else:
return False
def checkUserName(uname): #makes sure usernames are unique
for user in users:
if user.username == uname:
return False
return True

def newUser(): #creates a new user
uname = ""
while True:
uname = str(raw_input("Enter your username :\t"))
if checkUserName(uname) == False:
print("Username {} has already been taken".format(uname))
else:
break
pwd = str(raw_input("Enter your password:\t"))
newUser = User(uname,pwd)
users.append(newUser)
print("User created successfully! Please enter your credentials at the login page to Sign In.")
menu1()

def menu1(): #login menu
global currUser
while True:
print("\n\n\n*********ATM Menu*********")
print("1. Login")
print("2. New User? Register")
print("3. Exit")
x = int(raw_input("Enter your choice:\t"))
if x == 1:
uname = str(raw_input("Enter your username :\t"))
pwd = str(raw_input("Enter your password:\t"))
#print(uname,pwd)
res = login(uname,pwd)
if isinstance(res,tuple):
currUser = res[1]
menu2()
else:
print("Invalid Username/Password")
elif x == 2:
newUser()
else:
break

def menu2(): #user menu
global currUser
print("\n\n\nWelcome {}".format(currUser.username))
acccode_map = {"ch" : "checking","cr" : "credit", "sv" : "savings"}
while True:
acc_type = str(raw_input("\nEnter code for the account to query: Credit (cr) ; Checking (ch) ; Savings (sv):\t"))
if acc_type in acccode_map:
menu3(acccode_map[acc_type])
else:
print("Invalid choice! no such account type {}".format(acc_type))
back=str(raw_input("DO you want to logout (Y/n)?:\t"))
if back[0:1] == "Y" or back[0:1] == "y":
currUser = None
menu1()

def menu3(acc_type): #account menu
global currUser
max_tranaction = 500 #We cap the transaction at $500
print("\n\n\nSelected Account Type : {}".format(acc_type))
while True:
print("\n*****User Menu*****")
print("1. Check Balance")
print("2. Withdraw Money")
print("3. Deposit Money")
x = int(raw_input("Enter your choice:\t"))
if x == 1:
print ("Balance : {}".format(currUser.accounts[acc_type]))
elif x == 2:
bal = currUser.accounts[acc_type]
amount = int(raw_input("Enter amount:\t"))
if amount > bal:
print("Insufficient Balance! Transaction aborted.")
elif amount > 500:
print("Transactions are capped at a max of $500.")
else:
currUser.accounts[acc_type] = bal - amount;
print("Amount successfully withdrawn")
elif x == 3:
bal = currUser.accounts[acc_type]
amount = int(raw_input("Enter amount:\t"))
currUser.accounts[acc_type] = bal + amount
print("Amount successfully deposited")
back=str(raw_input("Go back to user menu (Y/n)?:\t"))
if back[0:1] == "Y" or back[0:1] == "y":
menu2()
if __name__ == "__main__":
menu1()

Indentation Screenshots:

Output Screenshots:


Related Solutions

CSE/EEE 230 Assignment 4 Fall 2019 Due Sept 30 (11:59PM) In this assignment, you are to...
CSE/EEE 230 Assignment 4 Fall 2019 Due Sept 30 (11:59PM) In this assignment, you are to complete a MIPS program so it will perform the required tasks. The main function of the code is provided. Do not change the code in the main function. There is a loop in the main function. You are to complete the program by writing two functions. Pay particular attention to the purpose of each function and how the parameters and return value are to...
This assignment is worth 4.0% of your final grade and is due by Thursday, 11:59 PM...
This assignment is worth 4.0% of your final grade and is due by Thursday, 11:59 PM ET of week 7. Instructions There are many tools available to assist you as an RN to organize your thoughts, make nursing judgments, and implement the 5 rights of delegation. SBAR – Situation, Background, Assessment, and Recommendation, is a standardized tool used in many institutions that provides a framework to facilitate clear communication between health care providers. The components of SBAR are as follows,...
Design a program that will receive a valid time in the 12-hour format (e.g. 11:05 PM)...
Design a program that will receive a valid time in the 12-hour format (e.g. 11:05 PM) and convert it to its equivalent 24-hour format (e.g. 2305). Assume 0000 in 24-hour format is 12:00AM in 12-hour format. The program should continue accepting inputs until a sentinel value of 99:99AM is entered. Ex: If the input is: 09:04AM 10:45AM 11:23AM 99:99AM IN Java please, Thanks the output is: 0904 1045 1123
Econ 335: Assignment 4 Due: April 20th by 11:59 PM 1.     To protect American jobs, the...
Econ 335: Assignment 4 Due: April 20th by 11:59 PM 1.     To protect American jobs, the US government may decide to cut US imports of bulldozers by 60%. It could do so by either: -Imposing a tariff high enough to cut bulldozer imports by 60% -Persuading Komatsu and other foreign bulldozer makers to set up a voluntary export restraint arrangement to cut their exports of bulldozers to the US by 60%. a. Which of these two policies would be less...
Ice to Steam via Water Due this Friday, Dec 4 at 11:59 pm (EST) How much...
Ice to Steam via Water Due this Friday, Dec 4 at 11:59 pm (EST) How much heat is required to change a 49.4 g ice cube from ice at -13.7°C to water at 50°C? (if necessary, use cice=2090 J/kg°C and csteam= 2010 J/kg°C) 2.82×104 J You are correct. Your receipt no. is 150-2609 Help: Receipt Previous Tries How much heat is required to change a 49.4 g ice cube from ice at -13.7°C to steam at 120°C?
Chapter 11 Exercise A4 Assume a company is going to make an investment of $450,000 in...
Chapter 11 Exercise A4 Assume a company is going to make an investment of $450,000 in a machine and the following are the cash flows that two different products would bring in years one through four. Option A, Product A Option B, Product B $190,000 $150,000 190,000 180,000 60,000 60,000 20,000 70,000 Which of the two options would you choose based on this payback method?
Scenario 2: It is now 11:30 pm. You are caring for a client with an indwelling...
Scenario 2: It is now 11:30 pm. You are caring for a client with an indwelling urinary catheter (14fr). You are emptying the collection device and measure a total of 130mL of cloudy urine. You enter the amount and notice that there has not been any other output charted since 3pm, which was 275mL. You check the tubing for any kinks and do not find any. The Foley remains secured and in place. The client’s abdomen is distended and firm...
PSY 2030 -Assignment 4: One-Way Anova -Due by Sunday, April 19th, at 11:30 PM -Scores out...
PSY 2030 -Assignment 4: One-Way Anova -Due by Sunday, April 19th, at 11:30 PM -Scores out of 25 points (16 points for Question and 9 points for Question 2) -Submit by uploading file(s) within "Assignment 4" on Canvas -SHOW ALL WORK!! Either very clearly type it (making sure your formulas and integrity/formatting of formulas are extremely clear) or write it out by hand and attach a scan or photo of your work. Remember that all assignments must reflect your own...
CSC 101 Assignment 3 Barista Assistant Due Date: Friday, October 30 at 11:59 PM Learning Objectives:...
CSC 101 Assignment 3 Barista Assistant Due Date: Friday, October 30 at 11:59 PM Learning Objectives: Practice combining your knowledge of conditionals, loops, functions, strings, and lists. What to Submit: Write your program in a Python script named barista.py. Submit this file to the Assignment 3 page on Canvas. Description The purpose of this assignment is to write a Python program for a cafe to help baristas create coffee for a customer. Your program will take the customer's order and...
Consider your own advanced care planning. What advanced directives might you consider? If you couldn’t make...
Consider your own advanced care planning. What advanced directives might you consider? If you couldn’t make your own decisions, who would you ask to do that for you? Do you have a living will? Where is it located? Does anyone know about it? What is included or what would you include in your living will? Who would be your power-of-attorney? What special cultural or religious beliefs do you want to be considered? Do you want anything special to happen after...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT