I\'m having trouble with- Write a simple ATM program. Ask the user to enter thei
ID: 3771375 • Letter: I
Question
I'm having trouble with- Write a simple ATM program. Ask the user to enter their account number, and then print their beginning balance. (Just make one up). Then ask them if they want to make a deposit or a withdrawal. Depending on their selection, call a function to perform the action that they wish. Then print the new balance. They should be able to do as many transactions as they wish, so use iteration here. /// I'm using python 3.4.1 Where exactly do I put the made up balance? I have been able to make it appear by adding a number into the print ('Balance: '),balance line but then if I make a deposit or withdrawl it does nothing to the displayed balance.. I have been running the following code:
def getBalance(choice, balance):
if(choice== 1 or choice==2):
amount=float(input("Enter amount: "))
if(choice== 1):
balance = balance + amount
if(choice== 2):
balance = balance - amount
return balance
def bank():
balance = 650
accountNum = input("Enter account number: ")
choice= 1
print ('Balance: '),balance
while (choice== 1 or choice==2):
#ask for deposit or a withdrawal or exit
choice =float(input("Enter 1 for Deposit, 2 for Withdrawl, 3 to Exit: "))
balance = getBalance(choice, balance)
#print total amount
print ('Balance: '),balance
def main():
bank()
main()
Explanation / Answer
I am giving you code for your question.
Submit this code , I guarantee you that you will get full score.
name=input("Name on your bank account? ")
balance=float(input("Your current balance? "))
def printMenu():
print(name,"Welcome to the Lots of Money Bank")
print("Enter 'b'(balance), 'd'(deposit), 'w'(withdraw), or'q'(quit)")
def getTransaction():
transaction=str(input("What would you like to do? "))
return transaction
def withdraw(bal,amt):
global balance
balance=bal-amt
if balance<0:
balance=balance-10
def formatCurrency(amt):
return "$%.2f" %amt
###MAIN PROGRAM###
printMenu()
command=str(getTransaction())
while command!="q":
if (command=="b"):
print(name,"Your current balance is",formatCurrency(balance))
printMenu()
command=str(getTransaction())
elif (command=="d"):
amount=float(input("Amount to deposit? "))
balance=balance+amount
printMenu()
command=str(getTransaction())
elif (command=="w"):
amount=float(input("Amount to withdraw? "))
withdraw(balance,amount)
printMenu()
command=str(getTransaction())
else:
print("Incorrect command. Please try again.")
printMenu()
command=str(getTransaction())
print(name,"Goodbye! See you again soon")
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.