-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathATM.py
42 lines (34 loc) · 1.18 KB
/
ATM.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class ATM:
def __init__(self, balance=10000):
self.balance = balance
def check_balance(self):
return f"Your account balance is {self.balance}"
def deposit(self, amount):
self.balance += amount
return f" You Deposited {amount}. Your new balance is {self.balance}"
def withdraw(self, amount):
if self.balance >= amount:
self.balance -= amount
return f" Your Withdrew {amount}. Your new balance is {self.balance}"
else:
return "Insufficient funds"
atm = ATM()
while True:
print("1. Check Balance")
print("2. Deposit")
print("3. Withdraw")
print("4. Exit")
choice = input("Enter your choice: ")
if choice == '1':
print(atm.check_balance())
elif choice == '2':
amount = float(input("Enter the deposit amount: "))
print(atm.deposit(amount))
elif choice == '3':
amount = float(input("Enter the withdrawal amount: "))
print(atm.withdraw(amount))
elif choice == '4':
print("Thank you for using the ATM ")
break
else:
print("Invalid. Please select a valid option.")