我正在尝试展示特定年数内,随着每年增加的百分比,薪水的变化。
print('Enter the strting salary: ', end ='')
SALARY = float(input())
print('Enter the annual % increase: ', end ='')
ANNUAL_INCREASE = float(input())
calculation1 = ANNUAL_INCREASE / 100
calculation2 = calculation1 * SALARY
calculation3 = calculation2 + SALARY
Yearloops = int(input('Enter number of years: '))
for x in range(Yearloops):
print(x + 1, calculation3 )
在将工资设为25000元、涨幅设为3%、年数设为5年后,这是我的输出结果。
1 25750.0
2 25750.0
3 25750.0
4 25750.0
5 25750.0
我需要再次将上一个答案乘以增加的百分比。应该像这样:
1 25000.00
2 25750.00
3 26522.50
4 27318.17
5 28137.72
有人可以展示给我如何做吗?谢谢。