MacroGuru
08-07-2005, 10:01 PM
Alright, I am in a Java class right now, and for homework, I have to build a mortgage application, and I have the Principal, Annual Rate, and Length hard coded in (part of the assignment)
Then, based off of that, I am to figure out the monthly payment.
/*POS/406
*Mortgage Application
*By Dennis Thomas
*Week Two Assignment**/
public class Mortgage{
public static void main(String[] arguments){
double dRate = 5.75; //Yearly Interest
int iAmount = 200000; //Loan Amount
int iTerm = 30; //Length of Loan in Years
double dMonthRate; //Monthly Interest Rate
int iMonthsTotal; //Total Months of the Loan
double dPayment; //Monthly Loan Payment
//Display prefigured information to the end user
System.out.println("\t\n Your Mortgage Amount is " + iAmount);
System.out.println("\t\n Your Yearly Interest Rate is " + dRate);
System.out.println("\t\n Your Term years are " + iTerm);
dMonthRate = dRate/(12 * 100);//figure out the Monthly Rate
System.out.println("\t\n Your Monthly Rate is " + dMonthRate);
iMonthsTotal = iTerm*12;//figure out the total months of the loan
System.out.println("\t\n Your total months on the loan are " + iMonthsTotal);
dPayment = iAmount*(dMonthRate/(1-(1+dMonthRate)*-iMonthsTotal));//figure out the monthly payment
System.out.println("\t\n Your Monthly Payment is " + dPayment);
}
}
running the formula of
Monthly Payment = Principal * (Monthly Interest / (1 - (1 + Monthly Interest) * -Number of Months)
The number does not a appear to be correct to me...
However, I can not see what I am doing wrong, can anyone look at it and see if they can point out what I am doing wrong...
Then, based off of that, I am to figure out the monthly payment.
/*POS/406
*Mortgage Application
*By Dennis Thomas
*Week Two Assignment**/
public class Mortgage{
public static void main(String[] arguments){
double dRate = 5.75; //Yearly Interest
int iAmount = 200000; //Loan Amount
int iTerm = 30; //Length of Loan in Years
double dMonthRate; //Monthly Interest Rate
int iMonthsTotal; //Total Months of the Loan
double dPayment; //Monthly Loan Payment
//Display prefigured information to the end user
System.out.println("\t\n Your Mortgage Amount is " + iAmount);
System.out.println("\t\n Your Yearly Interest Rate is " + dRate);
System.out.println("\t\n Your Term years are " + iTerm);
dMonthRate = dRate/(12 * 100);//figure out the Monthly Rate
System.out.println("\t\n Your Monthly Rate is " + dMonthRate);
iMonthsTotal = iTerm*12;//figure out the total months of the loan
System.out.println("\t\n Your total months on the loan are " + iMonthsTotal);
dPayment = iAmount*(dMonthRate/(1-(1+dMonthRate)*-iMonthsTotal));//figure out the monthly payment
System.out.println("\t\n Your Monthly Payment is " + dPayment);
}
}
running the formula of
Monthly Payment = Principal * (Monthly Interest / (1 - (1 + Monthly Interest) * -Number of Months)
The number does not a appear to be correct to me...
However, I can not see what I am doing wrong, can anyone look at it and see if they can point out what I am doing wrong...