Skip to content

Commit ed511b0

Browse files
Merge pull request #7 from SushantGiri34/atm-improvement-new
🔧 ATM Machine Code Improved with Input Validation and Loop Fixes
2 parents 01428ea + f74919c commit ed511b0

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

ATM Machine/ATM machine.py

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
balance = 1000
2-
print("""
3-
Welcome to ATM Machine
42

5-
Choose Transaction
3+
while True:
4+
print("Choose a transaction:")
5+
print("1. Balance Money")
6+
print("2. Withdraw Money")
7+
print("3. Deposit Balance")
8+
print("4. Exit")
9+
10+
option = int(input("Enter The Task Transaction (1/2/3/4): "))
611

7-
1)BALANCE
8-
2)WITHDRAW
9-
3)DEPOSIT
10-
4)EXIT
12+
if(option == 1):
13+
print("Your balance is ", balance)
1114

12-
""")
13-
option = int(input("Enter Transaction "))
14-
15-
if(option == 1):
16-
print("Your balance is ", balance)
17-
elif(option==2):
18-
withdraw = float(input("Enter amount to withdraw "))
19-
if(balance > withdraw):
20-
total = balance - withdraw
15+
elif(option==2):
16+
withdraw = float(input("Enter amount to withdraw "))
17+
if(balance > withdraw):
18+
total = balance - withdraw
19+
print("success")
20+
print("your new balance is :",total)
21+
else:
22+
print("insufficient Balance")
23+
24+
elif(option==3):
25+
deposit = float(input("Enter amount to deposit "))
26+
totalbalance = balance + deposit
2127
print("success")
22-
print("your new balance is :",total)
28+
print("total balnace now is: ", totalbalance)
29+
30+
elif(option==4):
31+
print("thanks for choosing us!")
32+
break
33+
2334
else:
24-
print("insufficient Balance")
25-
elif(option==3):
26-
deposit = float(input("Enter amount to deposit "))
27-
totalbalance = balance + deposit
28-
print("success")
29-
print("total balnace now is: ", totalbalance)
30-
elif(option==4):
31-
exit()
32-
else:
33-
print("no selected transaction")
35+
print("no selected transaction")

0 commit comments

Comments
 (0)