Front Office Football Central  

Go Back   Front Office Football Central > Archives > FOFC Archive
Register FAQ Members List Calendar Mark Forums Read Statistics

Reply
 
Thread Tools
Old 08-07-2005, 10:01 PM   #1
MacroGuru
Coordinator
 
Join Date: May 2003
Location: Utah
Java help - I don't think this is right...

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.

Code:
/*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...
__________________
"forgetting what is in the past, I strive for the future"

MacroGuru is offline   Reply With Quote
Old 08-07-2005, 11:16 PM   #2
Easy Mac
Registered User
 
Join Date: Nov 2001
Location: Here
This is probably horribly wrong, but try this:
dpayment = (iAmount+(iAmount*dMonthRate)/iMonthsTotal))

Doubt this is right, but it gives a number that looks reasonably normal.
Easy Mac is offline   Reply With Quote
Old 08-08-2005, 12:39 AM   #3
MacroGuru
Coordinator
 
Join Date: May 2003
Location: Utah
I tried that, but the monthly payment was like 20K it appeared to me.
__________________
"forgetting what is in the past, I strive for the future"
MacroGuru is offline   Reply With Quote
Old 08-08-2005, 01:13 AM   #4
Raven
College Prospect
 
Join Date: Oct 2000
Location: Baltimore, MD
payment = (initAmount / (1- ((1 + monIntRate)^-nMonths)))

is that right?
Raven is offline   Reply With Quote
Old 08-08-2005, 09:22 AM   #5
MacroGuru
Coordinator
 
Join Date: May 2003
Location: Utah
Quote:
Originally Posted by Raven
payment = (initAmount / (1- ((1 + monIntRate)^-nMonths)))

is that right?

This has provided the closest result so far...I guess the instructor might have to let me know if I am wrong or right.
__________________
"forgetting what is in the past, I strive for the future"
MacroGuru is offline   Reply With Quote
Old 08-08-2005, 10:18 AM   #6
Radii
Head Coach
 
Join Date: Jul 2001
http://www.mtgprofessor.com/formulas.htm

The following formula is used to calculate the fixed monthly payment (P) required to fully amortize a loan of L dollars over a term of n months at a monthly interest rate of c. [If the quoted rate is 6%, for example, c is .06/12 or .005].

P = L[c(1 + c)^n]/[(1 + c)^n - 1]
Radii is offline   Reply With Quote
Old 08-08-2005, 10:29 AM   #7
Radii
Head Coach
 
Join Date: Jul 2001
so I think: P = L[c(1 + c)^n]/[(1 + c)^n - 1]

is:

dPayment = iAmount * ( (dMonthRate * Math.pow((1+dMonthRate),iMonthsTotal)) / (Math.pow((1+dMonthRate),iMonthsTotal) - 1) );

... I think, I didn't actually try it out. Parentheses may need adjusting and there may be some casting required.
Radii is offline   Reply With Quote
Old 08-08-2005, 03:06 PM   #8
MacroGuru
Coordinator
 
Join Date: May 2003
Location: Utah
Quote:
Originally Posted by Radii
so I think: P = L[c(1 + c)^n]/[(1 + c)^n - 1]

is:

dPayment = iAmount * ( (dMonthRate * Math.pow((1+dMonthRate),iMonthsTotal)) / (Math.pow((1+dMonthRate),iMonthsTotal) - 1) );

... I think, I didn't actually try it out. Parentheses may need adjusting and there may be some casting required.

This works, a lot better than what I had...Thank you so much for your assistance
__________________
"forgetting what is in the past, I strive for the future"
MacroGuru is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Forum Jump


All times are GMT -5. The time now is 08:36 PM.



Powered by vBulletin Version 3.6.0
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.