所以我想用每年%的增长率来显示一定数量的年薪
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
有人能教我怎么做吗?谢谢。你知道吗
我想这会满足你的要求:
我打印了第一年外的循环,因为我们不想计算增长,根据你的规格
你需要把你的计算放在for循环中,这样它每年都会发生,而不是只发生一次
输入25000、3%和5年输出
稍微调整一下您的代码版本:
这将生成测试用例25000、3、5的以下输出:
相关问题 更多 >
编程相关推荐