package teresasmortgagepaymentcalculator; public class Teresa Mortgage Payment Calculator { private static double DPayment; private static double ddate; private static double dmonthlyinterest; private static int[] dinterest; private static double dmonthlyprincipal; private static double dpayment; private static double dmonthlybalance; private static int[] iTerm; //The main function for the mortgage calculator public static void main(String[] args) { //Declaring and constructing variables int [] iterm = {84, 180, 360}; double [] dInterest = {5.35, 5.5, 5.75}; double DPpayment, drate, damount = 200000, DMonthlyInterest,MonthlyPrincipal, DMonthlybalance; decimalformat toDigits = decimalformat(); //output for month to years System.out.println(); System.out.println (); System.out.println(); System.out.println("An 84-month loan equals a 7-year loan."); System.out.println("A 180-month loan equals a 15-year loan."); System.out.println("A 360-month loan equals a 30-year loan."); System.out.println(); //Loop for the varying Mortgage Rates and Payments int p; for (p = 0; p <= 2; p ++) { //Calculation for the monthly mortgage payment //Calculations Retrieved from http://www.1728.com/loanform.htm on 8/15/08 drate = dInterest[p] / 1200; DPayment = (damount * ddate) / (1 - math.pow(1 / (1 + drate), iterm[p])); dmonthlyinterest = (damount / 12) * (dinterest[p] / 100); dmonthlyprincipal = (dpayment - dmonthlyinterest); dmonthlybalance = (damount - dmonthlyprincipal); // Output for the loan information and the monthly payment int nbYear = iTerm[p] / 12; System.out.println(); System.out.println("Your Monthly Payment for a " + nbYear +" years loan of $200,000 at " + dinterest[p]+ "% is:" + twodigits.format (dpayment)); System.out.println(); } } private static decimalformat decimalformat() { throw new UnsupportedOperationException("Not yet implemented"); } //function for the calculation of the interest into the loan payment public double MonthlyInterest() { //Declaring Variables for interest on the loan double dMonthlyInterest = 0.0; double dAmount = 0.0; double dInterest = 0.0; //Calculation for monthly interest dMonthlyInterest = (dAmount / 12) * (dInterest / 100); return dMonthlyInterest; } //function for the calculation of the interest into the loan payment public double monthlyInterest() { //Declaring Variables for interest on the loan double dMonthlyInterest = 0.0; double dAmount = 0.0; double dInterest = 0.0; //Calculation for monthly interest dMonthlyInterest = (dAmount / 12) * (dInterest / 100); return dMonthlyInterest; } //function of the calculation of the monthly principal for the loan payment public static double monthlyPrincipal() { //Declaring Variables for monthly principal double dMonthlyPrincipal = 0.0; double dPayment = 0.0; double dMonthlyInterest = 0.0; //Calculations for monthly principal dMonthlyPrincipal = (dPayment - dMonthlyInterest); return dMonthlyPrincipal; } //function for the calculation of the monthy loan balance public static double monthlyBalance() { //Declaring Variables for monthly loan balance double dMonthlyBalance = 0.0; double dAmount = 0.0; double dMonthlyPrincipal = 0.0; //Calculations for monthly loan balance dMonthlyBalance = (dAmount - dMonthlyPrincipal); return dMonthlyBalance; } }

This post has been edited by **pbl**: 22 February 2010 - 09:39 PM

Reason for edit:: Your first post... code tags added free of charge