我试图创建一个程序,询问用户他们的本金,利率,和总年限。我希望我的计划能向他们展示他们每年的总回报率。我想从第一年开始。当我运行脚本时,它只显示一年的总利息。这是我到目前为止的情况。在
#Declare the necessary variables.
princ = 0
interest = 0.0
totYears = 0
year = 1
#Get the amont of principal invested.
print("Enter the principal amount.")
princ = int(input())
#Get the interest rate being applied.
print("Enter the interest rate.")
interest = float(input())
#Get the total amount of years principal is invested.
print ("Enter the total number of years you're investing this amonut.")
totYears = int(input())
for years in range(1, totYears):
total=year*interest*princ
years += 1
print (total)
谢谢你的帮助。在
这里有一些问题:
也许你需要这个:
^{pr2}$相关问题 更多 >
编程相关推荐