Question: Please fix this code, the starting balance is not calculating correctly. When I input 8 0 0 I should get 7 2 0 back as

Please fix this code, the starting balance is not calculating correctly. When I input 800 I should get 720 back as the starting value but it gives 712.80 instead. def repayment_plan(purchase_price):
down_payment_rate =0.10
annual_interest_rate =0.12
monthly_interest_rate = annual_interest_rate /12
monthly_payment_rate =0.05
down_payment = purchase_price * down_payment_rate
starting_balance = purchase_price - down_payment
balance = starting_balance
print("%4s %18s %16s %16s %14s %20s"%("Month", "Starting Balance", "Interest Owed", "Principal Owed", "Payment Owed", "Remaining Balance"))
for month in range(1,20):
interest = starting_balance * monthly_interest_rate
principal = monthly_payment_rate * purchase_price - interest
payment = purchase_price * monthly_payment_rate
starting_balance -= interest
balance -= payment
print("{:3d}{:14.2f}{:16.2f}{:16.2f}{:16.2f}{:16.2f}".format(month, starting_balance, interest, principal, payment, balance))
month +=1
purchase_price = float(input("Enter the purchase price: "))
if purchase_price >=0:
repayment_plan(purchase_price)
else:
print("End Repayment Plan.")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!