In: Computer Science
Write a program in Python to determine how many months it will take to pay off a $10,000 car loan with 4% interest. Choose your own monthly payment.
The following code is well commented and self explanatory. Please find screenshots for indentation and output.
Assuming monthly payment = 1000.
---------Code below----------------------
loanamount = 10000
interestrate = 4
monthlypayment = 1000
monthlyinterest = round((loanamount * interestrate/100/12),2)
monthlybalance = float(loanamount - (monthlypayment -
monthlyinterest))
print ("Month", " ", "Payment", " ", "Interest", " ",
"Balance")
print ("-----", " ", "-------", " ", "--------", " ",
"-------")
month = 0
while monthlybalance > 0 :
month += 1
print (month, " ", monthlypayment, " ",
monthlyinterest, " ", monthlybalance)
monthlyinterest = round((monthlybalance *
interestrate/100/12),2)
monthlybalance = float(monthlybalance -
(monthlypayment - monthlyinterest))
print ("Total months taken will be",month,"months.")
Hope this helps. Do upvote if you feel satisfied.
Thank you :)