擅长:python、mysql、java
<p>这应该使用EMI概念。将每月利息加在总金额上,减去每月支付的EMI金额。当余额小于或等于零时,则中断循环</p>
<p>下面修改的功能将打印要支付的EMI数量</p>
<pre><code>def conta ():
total = float(input('How much do you want to borrow? '))
qtoPg = float(input('What is the monthly payment amount? '))
annualInterest = float(input('What is the annual interest rate expressed as a percent? '))
rateMonth = (annualInterest*0.01)/12
nbalance = total
emis = 0
while nbalance > 0:
emis += 1
nbalance = nbalance + (rateMonth*nbalance)
nbal = qtoPg
if nbalance < qtoPg:
nbal = nbalance
nbalance -= qtoPg
if nbalance <= 0:
print(nbal)
print (emis)
</code></pre>