Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- balance = float(raw_input('Enter the outstanding balance on your credit card: '))
- annual_interest = float(raw_input('Enter the annual credit card interest rate as a decimal: '))
- minimum_payment = balance/12.0
- maximum_payment = (balance * (1 + (annual_interest / 12.0)) * 12.0) / 12.0
- new_balance = balance
- while balance != 0.0:
- monthly_payment = (minimum_payment + maximum_payment) / 2.0
- for month in range(1,13):
- new_balance = round((new_balance * (1 + (annual_interest / 12.0)) - monthly_payment),2)
- if new_balance <= 0.0:
- break
- if new_balance == 0.0:
- balance = new_balance
- elif new_balance > 0.0:
- minimum_payment = monthly_payment
- new_balance = balance
- else:
- maximum_payment = monthly_payment
- new_balance = balance
- print 'RESULT'
- print 'Monthly payment to pay off debt in 1 year:',round(monthly_payment,2)
- print 'Number of months needed:',month
- print 'Balance:',round(balance,2)
Advertisement
Add Comment
Please, Sign In to add comment