+ 6
đ*Daily challenge*đ¶đ Question : Write a program:â
Write a program that computes the net amount of a bank account based a transaction log from console input. The transaction log format is shown as following: D 100 W 200 ÂĄÂ D means deposit while W means withdrawal. Suppose the following input is supplied to the program: D 300 D 300 W 200 D 100 Then, the output should be: 500 Hints: In case of input data being supplied to the question, it should be assumed to be a console input.
4 Respostas
+ 5
net_amnt=0
for i in range(1,100):
a=print("Do you want to make any transaction?\n(type 1 for yes \n type 2 for no) ")
num=int(input("Choose one of them: "))
if num==1:
print("1. deposite\n 2. withdraw")
n=int(input("What to do? "))
if(n==1):
print("enter the amount to add: ")
d=int(input())
net_amnt+=int(d)
elif(n==2):
print("enter the amount to withdraw: ")
w=int(input())
net_amnt-=int(w)
else:
pass
else:
break
pass
if net_amnt<0:
print("You are not eligible to withdraw that much money. \nSORRY!!")
else:
print("Total amount in your account left: Rs.",net_amnt)
you can add range according to you anyway there is no much use of that.
+ 1
t=int(input())
total=0
while t!=0:
c, n=input().split()
n=int(n)
if c=='D':
total+=n
elif c=='W':
total-=n
t-=1
print(total)
#t is the number of transactions
#c is to determine whether it's a deposit or withdrawal
#n is the amount of money deposited or withdrawn
0
heres my new dose
check it out
https://www.sololearn.com/discuss/658245/?ref=app
0
how to calculate output i can't found anywhere