Application - Financial Mortgage Calculator
By: Monika • Study Guide • 308 Words • January 15, 2010 • 952 Views
Join now to read essay Application - Financial Mortgage Calculator
/*
Application Financial Mortgage Calculator
Date
Filename Mortgage_app.java
Created by
Revision
*/
import java.io.*;
import java.text.DecimalFormat;
//Setup new class
class Mortgage_app
{
public static void main(String[] args)
{
//declarations (array format)
double[][] d_Input = {{0.0535, 0.0550, 0.0575},{7, 15, 30}};
//setup data pass to class Mortgage_calc_app
Mortgage_calc_app calc1 = new Mortgage_calc_app();
Mortgage_calc_app calc2 = new Mortgage_calc_app();
Mortgage_calc_app calc3 = new Mortgage_calc_app();
calc1.setd_Rate(d_Input[0][0]);
calc1.seti_Term(d_Input[1][0]);
calc1.printStates();
calc2.setd_Rate(d_Input[0][1]);
calc2.seti_Term(d_Input[1][1]);
calc2.printStates();
calc3.setd_Rate(d_Input[0][2]);
calc3.seti_Term(d_Input[1][2]);
calc3.printStates();
}
}
//reuse initial class
class Mortgage_calc_app
{
//decimal format
DecimalFormat Currency = new DecimalFormat("$0.00");
DecimalFormat Count = new DecimalFormat("0");
//declarations
double d_Rate,d_Loan,d_Amount,d_intPay,d_Principal;
double i_Term,i_Count,i_Count2,i_Line;
//pull data from class Mortgage_app
void setd_Rate(double newValue)
{
d_Rate = newValue;
}
void seti_Term(double newValue)
{
i_Term = newValue;
}
void printStates()
{
//initialize declarations
d_Loan = 200000;
i_Count = 0;
i_Line = 0;
//calculation for the monthly payment
d_Amount = (d_Loan*((d_Rate/12)/(1-Math.pow((1+(d_Rate/12)),-(i_Term*12)))));
//output to standard IO
System.out.println("nttttAMORTIZATION TABLEnn");
System.out.println("n#tPaymentttBalancettPaid