Mortage Caculator
809439Oct 30 2010 — edited Oct 31 2010Can someone please help me out with this,I am a newby. This assignment is due Sunday!!
Write the program in Java (with a graphical user interface) and have it calculate and display the mortgage payment amount from user input of the amount of the mortgage, the term of the mortgage, and the interest rate of the mortgage. Allow the user to loop back and enter new data or quit. Please insert comments in the program to document the program.
//Author Antonio J. Thompson
//PRG421
//University of Phoenix
//Purpose of Mortgage Calculator is to calculate monthly payments for McBride Financial
//Public class heading with Class Name Mortgage
public class Mortgage {
public static void main(String[] args) //Main method stated followed by variables needed for formula input
{
/*int loanamount=200000; //Loam Amount
int loanterm=30; //Loan Term in Years
double remainingbalance=200000; //Starting intial balance
int linecount=20; //Identifying the number of lines displayed at a given time.
double interest=.0575;
double monthlyPayment=0;
double loanbalance=0;
double monthlyinterest=0;
double monthlyprincipal=0;
monthlyPayment = loanamount * (interest/12) / (1 - Math.pow((1 + interest/12), - loanterm * 12)); //Mortgage calculator formula.
System.out.println("Mortgage Calculator");
System.out.println("Loan Amount:");
System.out.println(loanamount);
System.out.println("Interest Rate");
System.out.println(interest);
System.out.println("Loan Term");
System.out.println(loanterm);
System.out.println();
System.out.println("****************************************Payment Schedule************************************");
System.out.println("Loan Payment" + monthlyPayment);
for (int x=1;x<=loanterm * 12;x++)
{
monthlyinterest = remainingbalance * (interest/12);
monthlyprincipal = monthlyPayment - monthlyinterest;
remainingbalance = remainingbalance - monthlyprincipal;
System.out.println("Schedule\t" + x + "\t" + monthlyinterest + "\t" + monthlyprincipal + "\t" + remainingbalance);
if (x % 20 == 0)
{
System.out.println("Press any key to continue");
try
{
System.in.read();
} catch (Exception e)
{;}
}
}
*/double loanamount = 200000; //Inserting Array Values
double [] dblmonthlyinterest = { 0.0535, 0.055, 0.0575};
int [] dblloanterm = {84, 180,360 };
double [] dblmonthlyPayment = {0, 0, 0};
double remainingbalance=200000;
double monthlyinterest=0;
double monthlyprincipal=0;
for (int y = 0; y < dblmonthlyinterest.length; y++) //Calculation making sure to define length of Array
{
dblmonthlyPayment[y] = loanamount * (dblmonthlyinterest[y]/12) / (1 - Math.pow((1 + dblmonthlyinterest[y]/12), - dblloanterm[y] * 12));
//Formula for Calculating payments\
//Print out to screen
System.out.println("Loan Amount:");
System.out.println(loanamount);
System.out.println("Interest Rate");
System.out.println(dblmonthlyinterest[y]);
System.out.println("Loan Term");
System.out.println(dblloanterm[y]);
System.out.println("Monthly Payment");
System.out.println(dblmonthlyPayment[y]);
System.out.println("****************************************Payment Schedule************************************");
remainingbalance = loanamount;
for (int x=1;x<= dblloanterm[y];x++)
{
monthlyinterest = remainingbalance * (dblmonthlyinterest[y]/12);
monthlyprincipal = dblmonthlyPayment[y] - monthlyinterest;
remainingbalance = remainingbalance - monthlyprincipal;
System.out.println("Schedule\t" + x + "\t" + monthlyinterest + "\t" + monthlyprincipal + "\t" + remainingbalance);
if (x % 20 == 0)
{
System.out.println("Press any key to continue");
try
{
System.in.read();
} catch (Exception e)
{;}
}
}
}
{