Skip to content

Commit b87ad1c

Browse files
committed
while loop added co4p2
1 parent 24f7cd5 commit b87ad1c

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

C04/C04_p2.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,31 @@ def withdraw(self,Amount):
1414
self.Balance= self.Balance-Amount
1515
def deposit(self,Amount):
1616
self.Balance= self.Balance+Amount
17+
def display(self):
18+
print("Account Number: ",self.number)
19+
print("Account Name: ",self.Name)
20+
print("Account type: ",self.Atype)
21+
print("Account Balance: ",self.Balance)
1722

1823
accno=int(input("Enter your acc No:"))
1924
name=input("Enter your Name:")
2025
obj =BankAccount(accno, name, "Savings")
21-
22-
print("Account Number: ",obj.number)
23-
print("Account Name: ",obj.Name)
24-
print("Account type: ",obj.Atype)
25-
print("Account Balance: ",obj.Balance)
26-
dep=int(input("Enter the value to deposite: "))
27-
obj.deposit(dep)
28-
print("Account Balance: ",obj.Balance)
29-
wid=int(input("Enter the value to withdraw: "))
30-
obj.withdraw(wid)
26+
print("\n1.Account info\n2.Deposit\n3.Withdraw\n4.Exit")
27+
while(1):
28+
29+
opt=int(input("Select your option:"))
30+
if opt == 1:
31+
obj.display()
32+
elif opt == 2:
33+
dep=int(input("Enter the value to deposite: "))
34+
obj.deposit(dep)
35+
print("Account Balance: ",obj.Balance)
36+
elif opt == 3:
37+
wid=int(input("Enter the value to withdraw: "))
38+
obj.withdraw(wid)
39+
print("Account Balance: ",obj.Balance)
40+
elif opt == 4:
41+
print("Exit")
42+
break
43+
else:
44+
print("Invalid Option")

0 commit comments

Comments
 (0)