Advertisement
petrissimo

OCW 6-00 sc. PS1

Nov 6th, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. from decimal import * # Decimal module
  2. getcontext().prec = 28
  3.  
  4. balance = float(raw_input('Enter the outstanding balance on the credit card: '))
  5. balanceStr = float(0) #Decimal module can't work with floats, needs to convert to string
  6.  
  7. annualRate = float(raw_input('Enter the annual interest rate on the credit card: '))
  8.  
  9. minPaymentRate = float(raw_input('Enter the minimum monthly payment rate on the credit card: '))
  10.  
  11.  
  12. print("\n")
  13.  
  14. monthly_rate = annualRate/12
  15.  
  16. print("\n")
  17.  
  18. months = int(0)
  19. minMonPay = float (0) #minimum monthly pay
  20. minMonPayStr = float (0)
  21. intsPaid = float (0) #interests paid
  22. principalPaid = float(0)
  23. principalPaidStr = float(0)
  24.  
  25. while months<12:
  26. months = months+1
  27. print 'month:', months
  28.  
  29. minMonPay = (minPaymentRate * balance)
  30. minMonPayStr = str(minMonPay)
  31. print 'minimum monthly payment:', '$', Decimal (minMonPayStr).quantize(Decimal('0.01'), rounding=ROUND_UP)
  32.  
  33. intsPaid = monthly_rate * balance
  34. principalPaid = minMonPay - intsPaid
  35. principalPaidStr = str(principalPaid)
  36. print 'principal Paid', '$', Decimal (principalPaidStr).quantize(Decimal('0.01'), rounding=ROUND_UP)
  37.  
  38. balance = (balance - (principalPaid))
  39. balanceStr = str(balance)
  40. print 'remaining balance', '$', Decimal (balanceStr).quantize(Decimal('0.01'), rounding=ROUND_UP)
  41.  
  42. print("\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement