Guest User

Untitled

a guest
Jan 20th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. monthlyInterestRate = annualInterestRate / 12
  2. MonthlyPaymentLowerBound = balance / 12
  3. MonthlyPaymentUpperBound = balance * ((1 + monthlyInterestRate)**12 / 12)
  4. balance2=balance
  5. ans=round((MonthlyPaymentUpperBound+MonthlyPaymentLowerBound)/ 2 + 0.01, 2)
  6.  
  7. while True:
  8.    
  9.    
  10.     for month in range(12):
  11.         balance2=balance2-ans
  12.         balance2=balance2 + balance2 * monthlyInterestRate
  13.     if abs(balance2) < 0.8:
  14.         break;
  15.    
  16.     if balance2 > 0:
  17.         MonthlyPaymentLowerBound=ans
  18.     elif balance2 < 0:
  19.         MonthlyPaymentUpperBound=ans
  20.    
  21.     ans=(MonthlyPaymentUpperBound+MonthlyPaymentLowerBound)/ 2.0+0.01
  22.     balance2=balance
  23.    
  24.  
  25. print('Lowest payment: ' + str(round(ans,2)))
Add Comment
Please, Sign In to add comment