00001 ## 00002 # 00003 # Program that will print out a table of factors to derive a 00004 # monthly payment for a mortgage, given the interest rate in %/yr 00005 # and the length of the mortgage in years. The user divides the 00006 # principal by 1000 and multiplies this by the table entry to get 00007 # the monthly payment. 00008 # 00009 # Copyright (C) 2002 GDS Software 00010 # 00011 # This program is free software; you can redistribute it and/or 00012 # modify it under the terms of the GNU General Public License as 00013 # published by the Free Software Foundation; either version 2 of 00014 # the License, or (at your option) any later version. 00015 # 00016 # This program is distributed in the hope that it will be useful, 00017 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 # GNU General Public License for more details. 00020 # 00021 # You should have received a copy of the GNU General Public 00022 # License along with this program; if not, write to the Free 00023 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00024 # MA 02111-1307 USA 00025 # 00026 # See http://www.gnu.org/licenses/licenses.html for more details. 00027 # 00028 00029 import math, sys 00030 __version__ = "$Id: mort.py,v 1.4 2002/08/21 12:41:48 donp Exp $" 00031 00032 interest_step = 0.5 00033 begin_interest = 2.0 00034 end_interest = 15.0 00035 00036 years = [3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30] 00037 00038 fp = sys.stdout 00039 00040 # Print the header information 00041 fp.write("Monthly payment per $1000 principal\n\n") 00042 fp.write(" Years\n") 00043 fp.write("%/yr ") 00044 for year in years: 00045 fp.write("%2d " % year) 00046 fp.write("\n" + "-" * 6) 00047 fp.write("-" * 6 * len(years) + "\n") 00048 00049 interest = begin_interest 00050 factor_array = [] 00051 00052 while interest <= end_interest: 00053 # Calculate the current row's factors 00054 factor_array = [] 00055 for i in xrange(len(years)): 00056 tmp=math.pow(1+interest/1200.0, -years[i]*12.0); 00057 factor = 1000.0*(interest/1200.0)/(1.0-tmp); 00058 factor_array.append(factor) 00059 # Now print the factors 00060 fp.write("%5.2f " % interest) 00061 for i in xrange(len(years)): 00062 fmt = "%5.2f " 00063 if factor_array[i] < 10.0: 00064 fmt = "%5.3f " 00065 if factor_array[i] >= 100.0: 00066 fmt = "%5.1f " 00067 fp.write(fmt % factor_array[i]) 00068 fp.write("\n"); 00069 interest = interest + interest_step 00070 00071 fp.write("\nExample: A 10 year loan of $38000 at 8.0% per year will require\n") 00072 fp.write("a payment of 38 * 12.13 = $461.\n\n") 00073 00074 fp.write("Formula: let i = yearly interest in %\n") 00075 fp.write(" T = time in years\n") 00076 fp.write(" A = (1 + i/1200)^(-T*12)\n") 00077 fp.write("Then factor = 1000 * (i/1200)/(1 - A)\n") 00078 00079 00080
© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved; If you reference this document or any part of this document you must use the citation verbatim (including the link) "© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved."
Notice: This source code contained in this document is NOT open source and is NOT being distributed as open source.
122,241 lines of code and growing...