如果一个人每个月只支付信用卡公司要求的最低月供,请编写一个程序计算一年后的信用卡余额。
我正在尝试编写一个程序来打印一年后要支付的最终余额
balance = 4213
annualInterestRate = 0.2
monthlyPaymentRate = 0.04
month = 1
new_balance = (balance - (balance*monthlyPaymentRate))*(1+(annualInterestRate/12))
while month < 13:
print "Month: " + str(month)
print "Minimum monthly payment: " + str(round(minimum_monthly_payment, 2))
print "Remaining balance: " + str(round(new_balance, 2))
month += 1
我的输出显示了这一点:
Month: 1
Minimum monthly payment: 168.52
Remaining balance: 4111.89
Month: 2
Minimum monthly payment: 168.52
Remaining balance: 4111.89
Month: 3
Minimum monthly payment: 168.52
Remaining balance: 4111.89
但我应该得到这样的东西:
Month: 1
Minimum monthly payment: 168.52
Remaining balance: 4111.89
Month: 2
Minimum monthly payment: 164.48
Remaining balance: 4013.2
Month: 3
Minimum monthly payment: 160.53
Remaining balance: 3916.8