Hello
I am trying to develop java code that displays the principle balance, interest paid over the term of the loan. Without a GUI. The principle loan amount is 200,000.00 with an interest rate of .0575 on a 30year term loan.
I have successfully computed the payment amount of 1167.15
Now with this information I must develop a loop that will reduce the principle by whatever is left over after paying that months interest. The following is the code doing this:
double interestPaid = loanBalance * interest/12;
double principlePayment = monthlyPayment-interestPaid;
double loanBalance = P-principlePayment;
My question is How does the computer know to replace the loanBalance, with the "new" loanBalance after a payment is applied?
I have tried to use the term in months "360" as a counter for the loop but I get a "reached end of file while parsing" when I attempt this.
Any ideas on how I can correct my code to achieve a working Mortgage Calculator?
Mortgage Calculator
Page 1 of 12 Replies - 762 Views - Last Post: 01 December 2010 - 02:10 PM
Replies To: Mortgage Calculator
#2
Re: Mortgage Calculator
Posted 01 December 2010 - 01:56 PM
"reached end of file while parsing" is an error that occurs when you have too little ending braces. These: }
Go through your program and indent it correctly. When you do this, you will notice that a } is missing somewhere. If you put it in, you will fix this issue. If you need further help please
so that we can further help you.
Go through your program and indent it correctly. When you do this, you will notice that a } is missing somewhere. If you put it in, you will fix this issue. If you need further help please
#3
Re: Mortgage Calculator
Posted 01 December 2010 - 02:10 PM
Heh I just finished that class about a week ago as for the question: Without being able to see all your code makes it harder to answer so I will best guess it.
During the loop to display the information I am assuming P = 200000.00
should actually not include the orginal variable for the primary loan amount because it is a constant, new need to use a variable like newLoanAmount and define it as a double where you are defining all your variables Here is an example:
Use the newLoanAmount as your counter for that loop and loop until until it equals 0.
Hope this helps
Mike
ps: do a search on this site for "Java Mortgage Calculator" and you will find lots of code that will help.
Quote
How does the computer know to replace the loanBalance, with the "new" loanBalance after a payment is applied?
During the loop to display the information I am assuming P = 200000.00
double loanBalance = P - principlePayment
should actually not include the orginal variable for the primary loan amount because it is a constant, new need to use a variable like newLoanAmount and define it as a double where you are defining all your variables Here is an example:
newLoanAmount = newLoanAmount - monthlyCost; //Redefine value for newLoanAmount
Quote
I have tried to use the term in months "360" as a counter for the loop
Use the newLoanAmount as your counter for that loop and loop until until it equals 0.
while (newLoanAmount01 > 0) {
newLoanAmount01 = newLoanAmount01 - monthlyCost01;
Hope this helps
Mike
ps: do a search on this site for "Java Mortgage Calculator" and you will find lots of code that will help.
This post has been edited by midhir: 01 December 2010 - 02:14 PM
Page 1 of 1

New Topic/Question
Reply



MultiQuote



|