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-22-2005, 04:17 PM   #1
MacroGuru
Coordinator
 
Join Date: May 2003
Location: Utah
Java Code Help - Again

Can anyone take a look at my program and tell me where the fault is at?

I am supposed to generate Amortization for 3 different mortgages, and I am getting 2 errors I cannot figure out.

Thanks

Code:
/* *POS/406 *Mortgage Application *By Dennis Thomas */ import java.text.*; import java.io.*; public class Mortgage{ public static void main(String[] arguments){ //Define Mortgage Array Mortgage[] arrMortgages = new mortgages[3]; //Define the objects in the array arrMortgage[0] = new Mortgage(200,000, 30, .0575); arrMortgage[1] = new Mortgage(200,000, 7, .0535); arrMortgage[2] = new Mortgage(200,000, 15, .055); double dPrincipal; int iTerm; double dRate; double dnumPayments; double dmonthlyPayment; int iPeriods = 12; // Loop rest of program through all 3 mortgages for (int x=0; x<3; x++) { // Display Loan Info before displaying Amoritization Table DisplayInfo(mortgages[x], x); Mortgage.pause(); // Display Amoritization Table for each loan mortgages[x].DisplayAmoritization(); Mortgage.pause(); public Mortgage(double dPrincipal, int iTerm, double dRate){ dnumPayments = iTerm*iPeriods dmonthlyPayment = this.MonthlyPayment } public void DisplayInfo(Mortgage m, int iNum){ //Display prefigured information to the end user NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); System.out.println("\t\n Your Mortgage Amount is" + nf.format(dPrincipal)); System.out.println("\t\n Your Yearly Interest Rate is " + dRate); System.out.println("\t\n Your Term years are " + iTerm); m.MonthlyRate(); m.TotalMonths(); m.MonthlyPayment(); } public double MonthlyRate(){ dMonthRate = dRate/(12 * 100);//figure out the Monthly Rate System.out.println("\t\n Your Monthly Rate is " + dMonthRate); } public int TotalMonths(){ iMonthsTotal = iTerm*12;//figure out the total months of the loan System.out.println("\t\n Your total months on the loan are " + iMonthsTotal); } public double MonthlyPayment(){ dmonthlyPayment = iAmount * ( (dMonthRate * Math.pow((1+dMonthRate),iMonthsTotal)) / (Math.pow((1+dMonthRate),iMonthsTotal) - 1) );//figure out the monthly payment NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); System.out.println("\t\n Your Monthly Payment is " + nf.format(dPayment)); } public void DisplayAmoritization(){ double dCurrentMonthlyInterest; double dPaymentAmount; double dPaymentBalance; double dp = dPrinciple; // changeable principle variable for this function double dMI = dRate/iPeriods; // monthly interest = interest/12 System.out.println("\t\tBalance\t\tMonthly Payment\t\tAmt Principle\t\tAmt Interest"); for (int x = 0; x < dnumPayments; x++) { //pause every 15 lines double numLines = 15.00; int dummy = (int)x/15; if (((x/numLines) == (double)dummy)&&(dummy != 0)) { Mortgage.pause(); } // figuring and outputting amortization stuff NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); dCurrentMonthlyInterest = dp * dMI; dPaymentAount = dmonthlyPayment - dCurrentMonthlyInterest; dPaymentBalance = dp - dPaymentAmount; System.out.println((x+1) + "\t\t" + nf.format(dp) + "\t\t" + nf.format(dmonthlyPayment) + "\t\t\t" + nf.format(dPaymentAmount) + "\t\t\t" + nf.format(dCurrentMonthlyInterest)); dp = dPaymentBalance; } } } } }
__________________
"forgetting what is in the past, I strive for the future"

MacroGuru is offline   Reply With Quote
Old 08-22-2005, 04:29 PM   #2
Surtt
College Benchwarmer
 
Join Date: Nov 2003
And the errors are?
Surtt is offline   Reply With Quote
Old 08-22-2005, 04:32 PM   #3
MacroGuru
Coordinator
 
Join Date: May 2003
Location: Utah
I am getting an illegal start of expression with the Public Mortgage function declaration and a ';' expected at line 104, however, I can not see where it is at, but this is using JCreator IDE, so if someone is using another IDE that might give more information it would be helpful.

Thanks,
__________________
"forgetting what is in the past, I strive for the future"
MacroGuru is offline   Reply With Quote
Old 08-22-2005, 04:34 PM   #4
MikeVic
Head Coach
 
Join Date: Mar 2003
Location: Hometown of Canada
You're missing two semi-colons on the function?

" dnumPayments = iTerm*iPeriods;
dmonthlyPayment = this.MonthlyPayment; "
MikeVic is offline   Reply With Quote
Old 08-22-2005, 04:35 PM   #5
MacroGuru
Coordinator
 
Join Date: May 2003
Location: Utah
Quote:
Originally Posted by MikeVic
You're missing two semi-colons on the function?

" dnumPayments = iTerm*iPeriods;
dmonthlyPayment = this.MonthlyPayment; "

I caught that, just as I posted this, I was also missing the () on the end of MonthlyPayment there as well...
__________________
"forgetting what is in the past, I strive for the future"
MacroGuru is offline   Reply With Quote
Old 08-22-2005, 04:36 PM   #6
MikeVic
Head Coach
 
Join Date: Mar 2003
Location: Hometown of Canada
And you're main doesn't have a closing curly brace?
MikeVic is offline   Reply With Quote
Old 08-22-2005, 04:37 PM   #7
MacroGuru
Coordinator
 
Join Date: May 2003
Location: Utah
Quote:
Originally Posted by MikeVic
And you're main doesn't have a closing curly brace?
It should on line 106....

Ignore this....I just found it and opened up a can of worms....

I will be back with new code.....
__________________
"forgetting what is in the past, I strive for the future"

Last edited by MacroGuru : 08-22-2005 at 04:40 PM.
MacroGuru is offline   Reply With Quote
Old 08-22-2005, 04:40 PM   #8
MikeVic
Head Coach
 
Join Date: Mar 2003
Location: Hometown of Canada
Maybe I'm rusty, but can you have all of these methods inside of main?
MikeVic is offline   Reply With Quote
Old 08-22-2005, 04:41 PM   #9
MikeVic
Head Coach
 
Join Date: Mar 2003
Location: Hometown of Canada
dola, I think you found what I was talking about then.
MikeVic is offline   Reply With Quote
Old 08-22-2005, 06:34 PM   #10
MacroGuru
Coordinator
 
Join Date: May 2003
Location: Utah
Mike,

thank you for pointing the things out you did, it actually helped me out a lot....I was able to finalize the code and get it working how it properly should.

Thank you!
__________________
"forgetting what is in the past, I strive for the future"
MacroGuru is offline   Reply With Quote
Old 08-22-2005, 06:50 PM   #11
MikeVic
Head Coach
 
Join Date: Mar 2003
Location: Hometown of Canada
No problem.
MikeVic is offline   Reply With Quote
Old 08-22-2005, 06:55 PM   #12
sterlingice
Hall Of Famer
 
Join Date: Apr 2002
Location: Back in Houston!
Dang, I keep missing out on these fairly easy Java threads. Be fun to solve some of those again

SI
__________________
Houston Hippopotami, III.3: 20th Anniversary Thread - All former HT players are encouraged to check it out!

Janos: "Only America could produce an imbecile of your caliber!"
Freakazoid: "That's because we make lots of things better than other people!"


sterlingice is offline   Reply With Quote
Old 08-22-2005, 07:05 PM   #13
Greyroofoo
Pro Starter
 
Join Date: Nov 2003
Location: Alabama
ahhhh, if only all my java problems were this easy
Greyroofoo is offline   Reply With Quote
Old 04-04-2008, 09:42 AM   #14
dacman
College Benchwarmer
 
Join Date: Oct 2000
Location: speak to the trout
There are several ways to do it.

1) Implement a method that sends a message to the other frames that a click happened in a different frame

2) Make all frames mouse listeners and re-cast the mouse actions to cause a mouse event to happen in every frame every time. (Ugly, and I personally wouldn't suggest it, but it's possible)

I'm sure there are other ways to do it -- but you will probably need a list of all instantiated frames, or possibly a unique higher level container to keep track of each frame.
__________________
No signatures allowed.

Last edited by dacman : 04-04-2008 at 09:45 AM.
dacman is offline   Reply With Quote
Old 04-04-2008, 03:52 PM   #15
cartman
Death Herald
 
Join Date: Nov 2000
Location: Le stelle la notte sono grandi e luminose nel cuore profondo del Texas
I'd like to point out that this is actual code, not macros.

__________________
Thinkin' of a master plan
'Cuz ain't nuthin' but sweat inside my hand
So I dig into my pocket, all my money is spent
So I dig deeper but still comin' up with lint
cartman 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 07:18 PM.



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