Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help, I want to create a program that simulates an ATM, that welcomes me, asks me to enter my account number, and then

I need help, I want to create a program that simulates an ATM, that welcomes me, asks me to enter my account number, and then my PIN, if the PIN is not valid it welcomes me, but if it is Valid, give me the options of:

1. Check my balance (and show me my balance and give me the options to return to the menu or exit).

2. withdraw money, (and give me the amount I have, give me the option to enter the amount I want to withdraw, and then show me the new balance, and give me the options to return to the menu or exit).

3. Change PIN, (change the program PIN and that this PIN is saved in the program and gives me the options to return to the menu or exit)

4. Exit

5. Register (give me the option to create a new 16-digit account, with your 4-digit PIN and the balance)

#accountnumber->[pin,balance] accounts={1:[123,100.20],2:[111,10.50],3:[222,1500.00], 4:[333,15.10],5:[100,2020.40]} menu=''' Options: 1.CheckBalance 2.WithdrawMoney 3.ChangePIN Yourchoice:''' defvalidated_pin(account): ''' Authenticatethepinvalue returnsTrueifthepinisthesamestoredinaccounts ''' pin=int(input("EnterPIN:")) correct_pin=account[0] returnpin==correct_pin defauthenticate(accounts): ''' Authenticatestheuserbycheckingthecountnumber andvalidatingpinvalue ''' account_number=int(input("Enteraccountnumber:")) if(account_numberinaccounts): if(validated_pin(accounts[account_number])): returnaccount_number returnNone defcontrol_option(option,account): ''' Controlswhateachoptionenteredshoulddo ''' if(option==1): balance=account[1] print("Balance:{}".format(balance)) elif(option==2): withdraw(account) elif(option==3): pin=int(input("NewPIN:")) account[0]=pin defwithdraw(account): ''' Asksforthevaluetowithdraw,validatedandshowsthenewbalance ''' value=float(input("Value:")) new_balance=account[1]-value if(value>3000ornew_balance<0): print("Invalidvalue.") else: account[1]=new_balance print("Balance:{}".format(new_balance)) defmain(menu,accounts): account_number=authenticate(accounts) if(account_numberisnotNone): option=int(input(menu)) control_option(option,accounts[account_number]) else: print("Invalidauthentication.Tryagain.") if__name__=="__main__": main(menu,accounts) 

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

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions