Mortgage
Essay by review • November 15, 2010 • Study Guide • 395 Words (2 Pages) • 1,043 Views
/*
File Name MortgageSchedule.java
Purpose Modify the mortgage program to display the mortgage payment
amount. Then, list the loan balance and interest paid for each payment
over the term of the loan. The list would scroll off the screen, but
use loops to display a partial list, hesitate, and then display more of
the list. Do not use a graphical user interface. Insert comments in
the program to document the program.
*/
import java.io.IOException;
import java.text.DecimalFormat;
public class MortgageSchedule //class header
{
public static void main(String[] args) //method header
{
DecimalFormat twoDigits = new DecimalFormat("0.00"); //formats the salary amount into 2 decimal places
//declare variables and arrays
double mortgage =200000;
double payment =0; //payment amount monthly
double interest =.0575; // Interest Rate (APR)
double interstmorate =(interest/12); //interest rate (monthly)
int term =30; // 30 years
int termmo =(term*12); //terms put into months
int linecount =20; //displays 20 lines
double totalpay =0; //Total mortgage amount + interest to be paid
double number =0; //number of payments made
double principalmo =0; //principal paid monthly
double interestmo =0; //interest paid monthly
double balance = mortgage;
// formats numbers to display only two decimal places
java.text.DecimalFormat dec = new java.text.DecimalFormat(",###.00");
//Caculate the Monthly Mortgage Payment
payment = (mortgage * interstmorate) / (1 - Math.pow(1 + interstmorate, - termmo));
//Print output of mortgage payment amount
System.out.println("Mortgage Amortization Program.");
System.out.println();
System.out.println("Mortgage Amount is $" + mortgage);
System.out.println("Interest Rate is "+ interest*100);
System.out.println("Loan Term in months is "+term*12);
System.out.println("Monthly Payment is $" + payment);
// Calculate Monthly Interest and Payments
interestmo
...
...