The following program has two mistakes in it that cause it to print an incorrect answer.
# Computes how much interest is earned on a given amount of principal.
principal = float(raw_input('Enter principal: '))
interestRate = float(raw_input('Enter interest rate as a percent: '))
years = int(raw_input('Enter number of years: '))
totInterest = 0.0
curYear = 0
while curYear <= years:
annualInterest = principal * interestRate
totInterest = totInterest + annualInterest
principal = principal + annualInterest
curYear = curYear + 1
print 'Total interest in ' + str(years) + ' year(s): $' + str(totInterest)
How do I correctly write the program to give me $100 for it is the correct answer.
Thanks,
MS