Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. class Account:
  2. def __init__(self, id, balance):
  3. self.id = id
  4. self.balance = balance
  5.  
  6. def getID(self):
  7. return self.id
  8.  
  9. def getBalance(self):
  10. return self.balance
  11.  
  12. def withdraw(self, amount):
  13. self.balance -= amount
  14.  
  15. def deposit(self, amount):
  16. self.balance += amount
  17.  
  18.  
  19. account_list = []
  20. for i in range(1000, 9999):
  21. account_list.append(i)
  22.  
  23. name = input("Enter your name: ")
  24. accid = int(input("Enter you account id (4-digits): "))
  25. balance = float(input("Enter your balance: "))
  26.  
  27. while True:
  28. if accid not in account_list:
  29. print("Error: Your account id does not exist...")
  30. accid = int(input("Please re-enter your ID: "))
  31. else:
  32. print("Welcome back! " + name.upper())
  33. break
  34.  
  35. accObj = Account(accid, balance)
  36.  
  37. while True:
  38. print("\n\nMAIN MENU:")
  39. print("1. DEPOSIT AMOUNT")
  40. print("2. WITHDRAW AMOUNT")
  41. print("3. BALANCE STATEMENT")
  42. print("4. EXIT")
  43.  
  44. choice = int(input("\nWhat do you want to do? "))
  45.  
  46. if choice == 1:
  47. amount = int(input("Please enter an amount you want to deposit... "))
  48. if(amount < 100):
  49. print("Minimum amount to deposit must be atleast $100!")
  50. else:
  51. accObj.deposit(amount)
  52. print("Your new balance is " + str(accObj.getBalance()))
  53.  
  54. elif choice == 2:
  55. amount = int(input("Please enter an amount you want to withdraw... "))
  56. check = input("\nIs this the amount you want to withdraw (Y/N)? ")
  57.  
  58. if check == "Y" or "y":
  59. print("\nProceeding...")
  60. else:
  61. break
  62.  
  63. if(amount < accObj.getBalance()):
  64. accObj.withdraw(amount)
  65. print("Your new balance is " + str(accObj.getBalance()))
  66. else:
  67. print("Invalid value to withdraw...")
  68. print("\nPlease deposit more money to your account.")
  69.  
  70. elif choice == 3:
  71. print("Here is your balance " + str(accObj.getBalance()))
  72.  
  73. elif choice == 4:
  74. print("Thanks for choosing us as your bank!")
  75. print("Have a nice day!")
  76. exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement