File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -3,19 +3,20 @@ def control_function():
3
3
choice = int (input ('your choice:' ))
4
4
if choice == 0 :
5
5
amount = int (input ('amount:' ))
6
- rate = int (input ('rate:' ))
6
+ rate = float (input ('rate:' ))
7
7
time = int (input ('time(year):' ))
8
8
finally_amount = 0
9
- finally_amount = amount * (1 + rate / 100 )** time
10
- print ('finally amount is' , finally_amount )
9
+ finally_amount = amount * (1 + rate )** time
10
+ print ('finally amount is {:.2f}' . format ( finally_amount ) )
11
11
elif choice == 1 :
12
12
amount = int (input ('amount:' ))
13
- rate = int (input ('rate:' ))
13
+ rate = float (input ('rate:' ))
14
14
time = int (input ('time(year):' ))
15
15
print ('amount:{}' .format (amount ))
16
16
for t in range (1 ,time + 1 ):
17
- amount = amount * (1 + rate / 100 )
18
- print ('year {}: ${}' .format (t ,amount ))
17
+ amount = amount * (1 + rate )
18
+ print ('year {}: ${:.2f }' .format (t ,amount ))
19
19
else :
20
20
print ('invaild input' )
21
+ control_function ()
21
22
control_function ()
You can’t perform that action at this time.
0 commit comments