Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Account:
- def __init__(self, id, balance):
- self.id = id
- self.balance = balance
- def getID(self):
- return self.id
- def getBalance(self):
- return self.balance
- def withdraw(self, amount):
- self.balance -= amount
- def deposit(self, amount):
- self.balance += amount
- account_list = []
- for i in range(1000, 9999):
- account_list.append(i)
- name = input("Enter your name: ")
- accid = int(input("Enter you account id (4-digits): "))
- balance = float(input("Enter your balance: "))
- while True:
- if accid not in account_list:
- print("Error: Your account id does not exist...")
- accid = int(input("Please re-enter your ID: "))
- else:
- print("Welcome back! " + name.upper())
- break
- accObj = Account(accid, balance)
- while True:
- print("\n\nMAIN MENU:")
- print("1. DEPOSIT AMOUNT")
- print("2. WITHDRAW AMOUNT")
- print("3. BALANCE STATEMENT")
- print("4. EXIT")
- choice = int(input("\nWhat do you want to do? "))
- if choice == 1:
- amount = int(input("Please enter an amount you want to deposit... "))
- if(amount < 100):
- print("Minimum amount to deposit must be atleast $100!")
- else:
- accObj.deposit(amount)
- print("Your new balance is " + str(accObj.getBalance()))
- elif choice == 2:
- amount = int(input("Please enter an amount you want to withdraw... "))
- check = input("\nIs this the amount you want to withdraw (Y/N)? ")
- if check == "Y" or "y":
- print("\nProceeding...")
- else:
- break
- if(amount < accObj.getBalance()):
- accObj.withdraw(amount)
- print("Your new balance is " + str(accObj.getBalance()))
- else:
- print("Invalid value to withdraw...")
- print("\nPlease deposit more money to your account.")
- elif choice == 3:
- print("Here is your balance " + str(accObj.getBalance()))
- elif choice == 4:
- print("Thanks for choosing us as your bank!")
- print("Have a nice day!")
- exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement