-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion17.py
More file actions
42 lines (35 loc) · 847 Bytes
/
question17.py
File metadata and controls
42 lines (35 loc) · 847 Bytes
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
36
37
38
39
40
41
42
'''
Question 17
Level 2
Question:
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.
'''
netAmount = 0
print('Deposit or withdraw money in specific format: D 100 or W 200')
while True:
s=input("")
if not s:
break
values = s.split(" ")
operation = values[0]
amount = int(values[1])
if operation == "D":
netAmount += amount
elif operation == "W":
netAmount -= amount
else:
pass
print(netAmount)