"); print("Mortgage Calculator"); print(""); print("

# PHP Mortgage Calculator

"); print("
\n\n"); \$print_footer = TRUE; } else { \$print_footer = FALSE; } // Style Sheet ?> Sale Price of Home, Length of Motgage and Annual Interest Rate"; } if (!\$error) { \$month_term = \$year_term * 12; \$down_payment = \$sale_price * (\$down_percent / 100); \$annual_interest_rate = \$annual_interest_percent / 100; \$monthly_interest_rate = \$annual_interest_rate / 12; \$financing_price = \$sale_price - \$down_payment; \$monthly_factor = get_interest_factor(\$year_term, \$monthly_interest_rate); \$monthly_payment = \$financing_price / \$monthly_factor; } } else { if (!\$sale_price) { \$sale_price = \$default_sale_price; } if (!\$annual_interest_percent) { \$annual_interest_percent = \$default_annual_interest_percent; } if (!\$year_term) { \$year_term = \$default_year_term; } if (!\$down_percent) { \$down_percent = \$default_down_percent; } if (!\$show_progress) { \$show_progress = \$default_show_progress; } } if (\$error) { print("" . \$error . "

\n"); \$form_complete = false; } ?> This mortgage calculator can be used to figure out monthly payments of a home mortgage loan, based on the home's sale price, the term of the loan desired, buyer's down payment percentage, and the loan's interest rate. This calculator factors in PMI (Private Mortgage Insurance) for loans where less than 20% is put as a down payment. Also taken into consideration are the town property taxes, and their effect on the total monthly mortgage payment.
= 20) \$pmi_per_month=0; // no PMI else { \$pmi_per_month = 55 * (\$financing_price / 100000); ?>
 Purchase & Financing Information Sale Price of Home: (In Dollars) Percentage Down: % Length of Mortgage: years Annual Interest Rate: % Explain Calculations: > Show me the calculations and amortization Start Over"); } ?> Mortgage Payment Information Down Payment: Amount Financed: Monthly Payment: (Principal & Interest ONLY) Since you are putting LESS than 20% down, you will need to pay PMI (Private Mortgage Insurance), which tends to be about \$55 per month for every \$100,000 financed (until you have paid off 20% of your loan). This could add to your monthly payment. Monthly Payment: (Principal & Interest, and PMI) Residential (or Property) Taxes are a little harder to figure out... In Massachusetts, the average resedential tax rate seems to be around \$14 per year for every \$1,000 of your property's assessed value. Let's say that your property's assessed value is 85% of what you actually paid for it - . This would mean that your yearly residential taxes will be around This could add to your monthly payment. TOTAL Monthly Payment: (including residential tax)

 The down payment = The price of the home multiplied by the percentage down divided by 100 (for 5% down becomes 5/100 or 0.05) \$ = \$ X ( / 100) The interest rate = The annual interest percentage divided by 100 = % / 100 The monthly factor = The result of the following formula: The monthly interest rate = The annual interest rate divided by 12 (for the 12 months in a year) = / 12 The month term of the loan in months = The number of years you've taken the loan out for times 12 Months = Years X 12 The montly payment is figured out using the following formula: Monthly Payment = * ( / (1 - ((1 + )-()))) The amortization breaks down how much of your monthly payment goes towards the bank's interest, and how much goes into paying off the principal of your loan.

Amortization For Monthly Payment: \\$" . number_format(\$monthly_payment, "2", ".", "thousands_sep") . " over " . \$year_term . " years
\n"); print("\n"); // This LEGEND will get reprinted every 12 months \$legend = "\t\n"; \$legend .= "\t\t\n"; \$legend .= "\t\t\n"; \$legend .= "\t\t\n"; \$legend .= "\t\t\n"; \$legend .= "\t\n"; echo \$legend; // Loop through and get the current month's payments for // the length of the loan while (\$current_month <= \$month_term) { \$interest_paid = \$principal * \$monthly_interest_rate; \$principal_paid = \$monthly_payment - \$interest_paid; \$remaining_balance = \$principal - \$principal_paid; \$this_year_interest_paid = \$this_year_interest_paid + \$interest_paid; \$this_year_principal_paid = \$this_year_principal_paid + \$principal_paid; print("\t\n"); print("\t\t\n"); print("\t\t\n"); print("\t\t\n"); print("\t\t\n"); print("\t\n"); (\$current_month % 12) ? \$show_legend = FALSE : \$show_legend = TRUE; if (\$show_legend) { print("\t\n"); print("\t\t\n"); print("\t\n"); \$total_spent_this_year = \$this_year_interest_paid + \$this_year_principal_paid; print("\t\n"); print("\t\t\n"); print("\t\t\n"); print("\t\n"); print("\t\n"); print("\t\t\n"); print("\t\n"); \$current_year++; \$this_year_interest_paid = 0; \$this_year_principal_paid = 0; if ((\$current_month + 6) < \$month_term) { echo \$legend; } } \$principal = \$remaining_balance; \$current_month++; } print("
 Month Interest Paid Principal Paid Remaing Balance " . \$current_month . " \\$" . number_format(\$interest_paid, "2", ".", "thousands_sep") . " \\$" . number_format(\$principal_paid, "2", ".", "thousands_sep") . " \\$" . number_format(\$remaining_balance, "2", ".", "thousands_sep") . " Totals for year " . \$current_year . " \n"); print("\t\t\tYou will spend \\$" . number_format(\$total_spent_this_year, "2", ".", "thousands_sep") . " on your house in year " . \$current_year . "\n"); print("\t\t\t\\$" . number_format(\$this_year_interest_paid, "2", ".", "thousands_sep") . " will go towards INTEREST\n"); print("\t\t\t\\$" . number_format(\$this_year_principal_paid, "2", ".", "thousands_sep") . " will go towards PRINCIPAL\n"); print("\t\t
\n"); } ?>
\n"); print(" \n"); } ?> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of David Tufts nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ?>