-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathatm_simulation.py
More file actions
35 lines (32 loc) · 1.08 KB
/
Copy pathatm_simulation.py
File metadata and controls
35 lines (32 loc) · 1.08 KB
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
class ATM:
def __init__(self, balance):
self.balance=balance
def check_balance(self):
print(f"Account Balance={self.balance}")
def deposit(self):
try:
self.balance+=float(input("Enter amount to deposit: "))
print("Deposit successful")
self.check_balance()
except ValueError:
print("Enter valid amount!")
def withdraw(self):
try:
self.balance-=float(input("Enter amount to withdraw: "))
print("withdraw successful")
self.check_balance()
except ValueError:
print("Enter valid amount!")
def atm_logic(self):
while True:
option=int(input("\nWelcome to the ATM!\n1. Check balance\n2. Deposit\n3. Withdraw\n4. Exit\nPlease choose an option: "))
if option==1:
self.check_balance()
elif option==2:
self.deposit()
elif option==3:
self.withdraw()
elif option==4:
break
user1=ATM(500)
user1.atm_logic()