Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Debt Payment Calculator
- #Takes in the necessary variables for the calculator
- outstanding_bal = float(raw_input('Please enter the outstanding balance on your credit card: '))
- annual_interest = float(raw_input('Please enter the annual credit card interest rate as a decimal: '))
- monthly_interest = annual_interest/12.0
- outstanding_bal_copy = outstanding_bal
- month = 1
- lower_payment = outstanding_bal_copy / 12.0
- upper_payment = (outstanding_bal_copy *(1+(annual_interest/12))**12.0)/12.0
- monthly_payment = (upper_payment + lower_payment) / 2.0
- #Finds the optimal monthly payment with interest
- while (outstanding_bal_copy > 0):
- ##print monthly_payment
- ##print outstanding_bal_copy
- outstanding_bal_copy = round((outstanding_bal_copy * (1 + monthly_interest) - monthly_payment), 2)
- if month > 12:
- month = 1
- if outstanding_bal_copy > 0:
- upper_payment = monthly_payment
- else:
- lower_payment = monthly_payment
- monthly_payment = (upper_payment + lower_payment) / 2.0
- outstanding_bal_copy = outstanding_bal
- continue
- month += 1
- month = month - 1
- if outstanding_bal_copy <= 0:
- print 'RESULT'
- print 'Monthly payment to pay off debt in 1 year: $' + str(monthly_payment)
- print 'Number of months needed: ' + str(month)
- print 'Balance: $' + str(outstanding_bal_copy)
Advertisement
Add Comment
Please, Sign In to add comment