Guest User

theode44

a guest
Mar 21st, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. #retirieve input
  2. balance = float(raw_input('Type balance:'))
  3. interestRate = float(raw_input('Type interest rate:'))
  4.  
  5. #initialize state variables
  6. monthlyRate = interestRate/12.0
  7. minPayment = 0
  8. postBalance = balance
  9.  
  10.  
  11. while balance > 0:
  12.  
  13.     minPayment += 10
  14.     postBalance = balance
  15.     numMonths = 0
  16.  
  17.  
  18.  
  19.     while numMonths < 12 and postBalance > 0:
  20.  
  21.             numMonths += 1
  22.  
  23.             interest = monthlyRate * postBalance
  24.  
  25.             postBalance -= minPayment
  26.  
  27.             postBalance += interest
  28.        
  29.  
  30. postBalance = round(postBalance,2)
  31.  
  32. print 'result'
  33. print 'Monthly payment to pay off debt in one year:', minPayment
  34. print 'Number of monthly payments:', numMonths
  35. print 'Balance:',postBalance
Advertisement
Add Comment
Please, Sign In to add comment