Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.58 KB | None | 0 0
  1. def number_of_years(l, i):
  2.     n = raw_input(' Enter your the number of years for the loan: ')
  3.     try:
  4.         n = float(n)
  5.         if n > 0:
  6.             print(' Loan amount is {0:.1f} \n'.format(l))
  7.             print(' Interest rate is {0:.4f} \n'.format(i))
  8.             print(' The number of years for the loan is {0:.1f} \n'.format(n))
  9.             m = (l * (i / 100) * n + l) / (n * 12)
  10.             print(' Your monthly payment is {0:.1f}'.format(m))
  11.  
  12.         else:
  13.             print(' Error 0x666 ')
  14.             number_of_years(l, i)
  15.     except ValueError:
  16.         print(' Error 0x666 ')
  17.         number_of_years(l, i)
  18.  
  19.  
  20. def interest_rate(l):
  21.     i = raw_input(' Enter your interest rate: ')
  22.     try:
  23.         i = float(i)
  24.         if i > 0:
  25.             print(' Loan amount is {0:.1f} \n'.format(l))
  26.             print(' Interest rate is {0:.4f} \n'.format(i))
  27.             number_of_years(l, i)
  28.         else:
  29.             print(' Error 0x666 ')
  30.             interest_rate(l)
  31.     except ValueError:
  32.         print(' Error 0x666 ')
  33.         interest_rate(l)
  34.  
  35.  
  36. def loan_amount(l):
  37.     try:
  38.         l = float(l)
  39.         if l > 0:
  40.             print(' Loan amount is {0:.1f} \n'.format(l))
  41.             interest_rate(l)
  42.         else:
  43.             print(' Error 0x666 ')
  44.             loan_amount()
  45.     except ValueError:
  46.         print(' Error 0x666 ')
  47.         loan_amount()
  48.  
  49.        
  50. print(' Input "q" to quit ')
  51.  
  52. while True:
  53.     l = raw_input(' Enter your loan amount: ')
  54.     if l == 'q':
  55.         break
  56.     loan_amount(l)
  57.     continue
  58.  
  59.  
  60. print(' Thank you for using the app. ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement