511 words - 3 pages

/*Programmer:SkySharkFile:MortgageCalculator5.javaDate:June 23,2008Purpose:To calculate and display the mortgage of the hard coded terms- 7 year at 5.35%- 15 year at 5.5%- 30 year at 5.75%*/import java.text.NumberFormat; //for currency formatimport java.util.*; //for Scannerimport static java.lang.System.out;import java.io.*;public class MortgageCalculator5{public static void main (String [] args)throws IOException{double loanAmount = 200000; //Loan amountdouble monthlyInt[] = {5.35, 5.50, 5.75}; //Monthly interest ratedouble monthlyPayment = 0; //Monthly paiddouble payments = 0;//Paymentdouble interestpaid = 0;//Interest paiddouble principalpaid = 0;//Principal paiddouble interest = 0;//Interestint loanTerm[] = {7, 15, 30}; //Term in year, arrayint lineCount = 1;// Int line ...view middle of the document...

println("\nYour monthly payment will be: " + currency.format (monthlyPayment) + "\n");out.printf("%s%15s%20s%20s\n", "Payment#", "Balance", "Principle Paid", "Interest Paid");while (lineCount key to continue ...\n");System.in.read(); //read in}}break;case 2:loanAmount = 200000.00; // reset loan amountlineCount = 1; //reset line countmonthlyPayment = calculate(loanAmount, monthlyInt[1], loanTerm[1]) ;out.println("\nYour monthly payment will be: " + currency.format(monthlyPayment) + "\n");out.printf("%s%15s%20s%20s\n", "Payment#", "Balance", "Principle Paid", "Interest Paid");while (lineCount key to continue ...\n");System.in.read(); //read in}}break;case 3:loanAmount = 200000.00; // reset loan amountlineCount = 1; //reset line countmonthlyPayment = calculate(loanAmount, monthlyInt[2], loanTerm[2]) ;out.println("\nYour monthly payment will be: " + currency.format(monthlyPayment) + "\n");out.printf("%s%15s%20s%20s\n", "Payment#", "Balance", "Principle Paid", "Interest Paid");while (lineCount key to continue ...\n");System.in.read(); //read in}}break;}out.println();out.println();}else //choice 4 was selectedout.println("\nThank You and come to see us again.\n");} // end of while} // end of mainpublic static double calculate(double Amount, double MonthInt, int Term) // calculation{double Monthly;Term = Term * 12;MonthInt = MonthInt / 100 / 12;Monthly = ( Amount * Math.pow((1 + MonthInt), Term) * MonthInt) /( Math.pow( (1 + MonthInt), Term ) - 1 );return Monthly;}private static void ShowMenu() // menu setup{out.println(" M E N U");out.println("\n");out.println("1. 7 Years at interest rate 5.35%");out.println("2. 15 Years at interest rate 5.50%");out.println("3. 30 Years at interest rate 5.75%");out.println("4. End program \n");out.print("\nEnter your choice: ");} // end function ShowMenu} // end of class

Get inspired and start your paper now!