Question: Why is my code looping for infinity? Here is the question prompt: The credit plan at TidBit Computer Store specifies a 1 0 % down

Why is my code looping for infinity? Here is the question prompt:
The credit plan at TidBit Computer Store specifies a 10% down payment and an annual interest rate of 12%. Monthly payments are 5% of the listed purchase price, minus the down payment.
Write a program in the file tidbit.py that takes the purchase price as input. The program should display a table, with appropriate headers, of a payment schedule for the lifetime of the loan. Each row of the table should contain the following items:
the month number (beginning with 1)
the current total balance owed
the interest owed for that month
the amount of principal owed for that month
the payment for that month
the balance remaining after payment
The amount of interest for a month is equal to balance * rate /12. The amount of principal for a month is equal to the monthly payment minus the interest owed. (LO: 3.2,3.3,3.4)
My code:
# Request the inputs and convert values
downPayment =0.10
annualInterest =0.12
paymentPercentage =0.05
purchasePrice = float(input("Enter the purchase price: "))
#calculate starting, monthly interest, and payment
startingBalance = purchasePrice -(purchasePrice * downPayment)
payment = startingBalance * paymentPercentage
interest = annualInterest /12
month =1
#display the header
print("%7s%18s%17s%18s%9s%16s"%("Month", "Starting Balance", "Interest to Pay",
"Principal to Pay", "Payment", "Ending Balance"))
#compute and display results
while startingBalance >0:
if startingBalance < payment:
principal = startingBalance
payment = startingBalance
interest =0
else:
interest = startingBalance * interest
principal = payment - interest
endingBalance = startingBalance - principal
print("%5d%15.2f%16.2f%18.2f%14.2f%17.2f"%(month, startingBalance,
interest, principal, payment, endingBalance))
startingBalance = endingBalance
month +=1

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!