Purchase Solution

Week four mortgage calculator program using Java JDK 1.5.0

Not what you're looking for?

Ask Custom Question

Is this a correct compilation for this program modification? I also need comments throughout the code aswell. The code below should Modify the mortgage program to display 3 mortgage loans: 7 year at 5.35%, 15 year at 5.5 %, and 30 year at 5.75%. Use an array for the different loans (the array will be needed in the next course). Display the mortgage payment amount for each loan. Do not use a graphical user interface. Insert comments in the program to document the program.
_________________________________________________________________________

import java.math.*;
import java.text.*;

//class BuyaHomeCalculator

class BuyaHomeCalculator {
public static void main(String arguments[]) {

//Program Variables
double term1 = 84;
double term2 = 180;
double term3 = 360;
double interestRate1 = 0.0535;
double interestRate2 = 0.055;
double interestRate3 = 0.0575;
double loan = 200000;

double term, interestRate;

DecimalFormat df = new DecimalFormat("$###,###.00");

//Calculates the Payment per month to be paid under mortgage scheme One
interestRate=interestRate1;
term=term1;
double monthlyRate = (interestRate/12);
double discountFactor = (Math.pow((1 + monthlyRate), term) -1) / (monthlyRate * Math.pow((1 + monthlyRate), term));
double payment1 = loan / discountFactor;
//Output for mortage scheme One
System.out.println("The Loan amount is:"+df.format(loan)+"n");
System.out.println("The intrest rate is:"+interestRate*100+"%");
System.out.println("The term of the loan is:"+term/12+" years.");
System.out.println("Monthly Payment Amount: " + df.format(payment1)+"n");

//Calculates the Payment per month to be paid under mortgage scheme Two
interestRate=interestRate2;
term=term2;
monthlyRate = (interestRate/12);
discountFactor = (Math.pow((1 + monthlyRate), term) -1) / (monthlyRate * Math.pow((1 + monthlyRate), term));
double payment2 = loan / discountFactor;
//Output for mortgage scheme Two
System.out.println("The intrest rate is:"+interestRate*100+"%");
System.out.println("The term of the loan is:"+term/12+" years.");
System.out.println("Monthly Payment Amount: " + df.format(payment2) +"n");

//Calculates the Payment per month to be paid under mortgage Three
interestRate=interestRate3;
term=term3;
monthlyRate = (interestRate/12);
discountFactor = (Math.pow((1 + monthlyRate), term) -1) / (monthlyRate * Math.pow((1 + monthlyRate), term));
double payment3 = loan / discountFactor;
//Output for morgage scheme Three
System.out.println("The intrest rate is:"+interestRate*100+"%");
System.out.println("The term of the loan is:"+term/12+" years.");
System.out.println("Monthly Payment Amount: " + df.format(payment3)+"n");

}
}

Purchase this Solution

Purchase this Solution


Free BrainMass Quizzes
Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic Networking Questions

This quiz consists of some basic networking questions.