ReviewEssays.com - Term Papers, Book Reports, Research Papers and College Essays
Search

Mortgage Calculator Jave

Essay by   •  February 8, 2011  •  Study Guide  •  1,115 Words (5 Pages)  •  1,214 Views

Essay Preview: Mortgage Calculator Jave

Report this essay
Page 1 of 5

/* Week 2 individual assignment by William Velez

Version 1.1

Edited by William Velez on September 27th, 2007

MortgageCalc.java

Write a Java program without a graphical user interface that calculates and displays the mortgage payment amount given the amount of the mortgage, the term of the mortgage, and the interest rate of the mortgage. In this program, hard code the amount = $200,000, the term = 30 years, and the interest rate = 5.75%. Insert comments in the program to document the program.

*/

public class MortgageCalc

{

public static void main (String[] args)

{

double mortgagedAmount = 200000; //hard coded mortgaged amount

int year = 30; //years of loan

double interestRate = 5.75; //hard coded interest rate

double monthlyInterest;

double numberOfMonths;

double monthTotalPayment;

double interestPayed;

double principlePayment;

int month = 1;

//Displaying the amount mortgaged with interest rate and life of the loan in years

System.out.print("nThe mortgage amount is: $");

System.out.println(mortgagedAmount);

System.out.print("The life of the loan in years is: ");

System.out.println(year);

System.out.print("The interest rate given is: %");

System.out.println(interestRate);

// The program will now calculate and display the mortgage payment amount

//Given the link http://www.hughchou.org/calc/formula.html which shows how to calculate mortgage amounts

//First we will calculate monthly interest

monthlyInterest = interestRate/(12*100);

//Calculate number of Months from the amount of years

numberOfMonths = year*12;

//Now to calculate monthly payment

monthTotalPayment = mortgagedAmount * (monthlyInterest / (1 - Math.pow((1 + monthlyInterest), -numberOfMonths)));

//Rounding off number which is in long form now

monthTotalPayment = Math.round(monthTotalPayment*100);

monthTotalPayment = monthTotalPayment / 100;

System.out.print("The monthly payment is: $");

System.out.println(monthTotalPayment);

for (int count=0; count0; av-- ) {

System.in.read();

} //close system read

interestPayed = mortgagedAmount * monthlyInterest;

interestPayed = Math.round(interestPayed *100);

interestPayed = interestPayed / 100;

mortgagedAmount = Math.round(mortgagedAmount *100);

mortgagedAmount = mortgagedAmount / 100;

System.out.println("nPayment #"+ month + "tMortgaged Amount: $" +mortgagedAmount+

"tInterest Paid: $" + interestPayed +".");

month++;

principlePayment = monthTotalPayment - interestPayed;

mortgagedAmount = mortgagedAmount - principlePayment;

interestPayed = mortgagedAmount * monthlyInterest;

interestPayed = Math.round(interestPayed *100);

interestPayed = interestPayed / 100;

mortgagedAmount = Math.round(mortgagedAmount *100);

mortgagedAmount = mortgagedAmount / 100;

System.out.println("Payment #"+ month + "tMortgaged Amount: $" +mortgagedAmount+

"tInterest Paid: $" + interestPayed +".");

month++;

principlePayment = monthTotalPayment - interestPayed;

mortgagedAmount = mortgagedAmount - principlePayment;

interestPayed = mortgagedAmount * monthlyInterest;

interestPayed = Math.round(interestPayed *100);

interestPayed = interestPayed / 100;

mortgagedAmount = Math.round(mortgagedAmount *100);

mortgagedAmount = mortgagedAmount / 100;

System.out.println("Payment #"+ month + "tMortgaged Amount: $" +mortgagedAmount+

"tInterest Paid: $" + interestPayed +".");

month++;

...

...

Download as:   txt (12.7 Kb)   pdf (136.9 Kb)   docx (11.6 Kb)  
Continue for 4 more pages »
Only available on ReviewEssays.com