Advertisement
coding_giants

l16 atm base

Nov 16th, 2023 (edited)
892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def main_menu():
  2.     print("Select an option:")
  3.     print("1. Deposit")
  4.     print("2. Withdrawal")
  5.     print("3. Check account balance")
  6.     print("4. Exit")
  7.  
  8. def get_customer_choice():
  9.     return int(input("your choice is: "))
  10.  
  11. def get_amount(text):
  12.     return float(input(text))
  13.  
  14. def show_account_balance(balance):
  15.     print(f"The account balance is {balance}")
  16.  
  17.  
  18. def deposit(balance):
  19.     deposit_amount = get_amount("How much would you like to deposit?")
  20.     balance = balance + deposit_amount
  21.     show_account_balance (balance)
  22.     return balance
  23.  
  24.  
  25. def withdrawal(balance):
  26.     withdrawal_amount = get_amount("How much would you like to withdraw?")
  27.     if withdrawal_amount > balance:
  28.         print("Operation failed, not enough funds on the account ")
  29.         return balance
  30.     else:
  31.         balance -= withdrawal_amount
  32.         print(f"The amount withdrawn {withdrawal_amount}")
  33.         return balance
  34.  
  35. #we write all the functions of our program above!!!
  36. choice = 0
  37. balance = 0
  38. #below is the main loop of the program
  39. while choice != 4:
  40.     main_menu()
  41.     choice = get_customer_choice()
  42.     if choice == 1:
  43.         balance = deposit(balance)
  44.         pass
  45.     elif choice == 2:
  46.         balance = withdrawal(balance)
  47.         pass
  48.     elif choice == 3:
  49.         show_account_balance(balance)
  50.         pass
  51.     elif choice == 4:
  52.         print("Shutting down the ATM")
  53.         pass
  54.     else:
  55.         print("Invalid data")
  56.         pass
  57.     pass
  58.  
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement