nicokruk

MIT 6.00SC - Problem Set 1 - Problem 2

Jun 10th, 2012
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. initial_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. monthly_interest = annual_interest/12.0
  4. multiples_of_ten = 1
  5. monthly_payment = 10
  6. termination_checker = 0
  7.  
  8. for multiples_of_ten in range (1, (int(initial_balance/10)+1)):
  9.     balance = initial_balance
  10.     total_paid = 0
  11.     months = 1
  12.     while termination_checker == 0 and months <=12:
  13. ##        print 'Month:', months
  14.         total_paid += monthly_payment * multiples_of_ten
  15. ##        print 'Monthly payment was: $',monthly_payment * multiples_of_ten
  16. ##        print 'Total paid so far on month #',months,'is $',total_paid
  17.         balance = balance * (1 + monthly_interest) - (monthly_payment * multiples_of_ten)
  18. ##        print 'Balance after month #',months,'is $',balance
  19. ##        print 'Current monthly payment multiplier is 10 *',multiples_of_ten
  20. ##        print '--------------------------------------------'
  21.         if balance <= 0:
  22.             print '**************************************'
  23.             print 'RESULT'
  24.             print 'Monthly payment to pay off debt in 1 year: $', monthly_payment * multiples_of_ten
  25.             print 'Number of months needed:', months
  26.             print 'Balance: $',round(balance,2)
  27.             print '***************************************'
  28.             termination_checker = 1
  29.         else:
  30.             months += 1
Advertisement
Add Comment
Please, Sign In to add comment