擅长:python、mysql、java
<p>你需要把你的计算放在for循环中,这样它每年都会发生,而不是只发生一次</p>
<pre><code>salary = float(input('enter starting salary: '))
annual_increase = float(input('enter the annual % increase: '))
years = int(input('enter number of years: '))
for x in range(years):
print(x + 1, salary)
increase = (annual_increase/100) * salary
salary += increase
</code></pre>
<p>输入25000、3%和5年输出</p>
<pre><code>1 25000.0
2 25750.0
3 26522.5
4 27318.175
5 28137.72025
</code></pre>