SHOW:
|
|
- or go back to the newest paste.
| 1 | balance = float(raw_input('Enter the outstanding balance on your credit card: '))
| |
| 2 | annual_interest = float(raw_input('Enter the annual credit card interest rate as a decimal: '))
| |
| 3 | minimum_payment = balance/12.0 | |
| 4 | maximum_payment = (balance * (1 + (annual_interest / 12.0)) * 12.0) / 12.0 | |
| 5 | new_balance = balance | |
| 6 | monthly_payment = (minimum_payment + maximum_payment) / 2.0 | |
| 7 | ||
| 8 | - | monthly_payment = (minimum_payment + maximum_payment) / 2.0 |
| 8 | + | |
| 9 | for month in range(1,13): | |
| 10 | new_balance = round((new_balance * (1 + (annual_interest / 12.0)) - monthly_payment),2) | |
| 11 | if new_balance <= 0.0: | |
| 12 | break | |
| 13 | if new_balance == 0.0: | |
| 14 | balance = new_balance | |
| 15 | elif new_balance > 0.0: | |
| 16 | minimum_payment = monthly_payment | |
| 17 | new_balance = balance | |
| 18 | else: | |
| 19 | maximum_payment = monthly_payment | |
| 20 | new_balance = balance | |
| 21 | ||
| 22 | print 'RESULT' | |
| 23 | print 'Monthly payment to pay off debt in 1 year:',round(monthly_payment,2) | |
| 24 | print 'Number of months needed:',month | |
| 25 | print 'Balance:',round(balance,2) |