+ 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.

14th Aug 2017, 3:30 PM
⓱ⓐⓝⓓⓔⓔⓟ
⓱ⓐⓝⓓⓔⓔⓟ - avatar
4 Answers
+ 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.
19th Jul 2020, 11:34 AM
Tanisha Gupta
Tanisha Gupta - avatar
+ 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
18th Aug 2017, 12:54 AM
Anan Gamal
26th Aug 2017, 3:35 AM
sayan chandra
sayan chandra - avatar
0
how to calculate output i can't found anywhere
6th Jun 2018, 5:18 AM
Sowmya Reddy
Sowmya Reddy - avatar