calculation

I am trying to get the below amortization calculation to work for a mortgage program. The mortgage payment calculation works fine but i get an error on variable when i go to create the amortization schedule. is something wrong??


double newRate = rateValue / 100;
double J = newRate / 12;
//double moInC=(newRate*12)/100;

// to display amount in correct format
DecimalFormat df = new DecimalFormat("$#,###.00");

double mortgage = (Math.pow((1 + J), termValue) - 1)
/ (J * Math.pow((1 + J), termValue));
double payment = amountValue / mortgage; // *Rate Calculation

gui.paymtField.setText("" + df.format(payment));

}

/*double newPrinC = amountValue;                  <------------------this is the amortization that does not work.
{
for (int i = 0; i <= 480; i++)
{

double newInC = J * newPrinC;
double reductionC = payment - newInC;
newPrinC = newPrinC - reductionC;

gui.textField.append("");
gui.textField.append(" " + +i);
gui.textField.append(" " + "\t" + df.format(newInC));
gui.textField.append(" " + "\t" + df.format(reductionC));
gui.textField.append(" " + "\t" + df.format(newPrinC) + "\n");
}
}//*/
pgmtklAsked:
Who is Participating?
 
WebstormConnect With a Mentor Commented:
in the following :


gui.paymtField.setText("" + df.format(payment));

}              //  <-- to be removed

/*double newPrinC = amountValue;
{              //  <-- to be removed
for (int i = 0; i <= 480; i++)

0
 
appxpeteCommented:
This line of code looks a little strange.  What are you trying to do here.  I would expect the compiler to complain about it.

gui.textField.append(" " + +i);
0
 
WebstormCommented:
if  gui.textField  is a TextField/JTextField, then you should use TextArea/JTextArea instead.

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
pgmtklAuthor Commented:
The text field area is ok, this is a gui program. The mortgage payment calculation works fine and displays the amount on the gui screen. Howver when i go to add the amortization portion i get error symbol  : variable J
location: class ThursdaySupportWeek4
double newInC = J * newPrinC;
                ^
1 error.

the j variable is defined but does not work in this section and i do not know why



double newPrinC = amountValue;                  <------------------this is the amortization that does not work.
{
for (int i = 0; i <= 480; i++)
{

double newInC = J * newPrinC;
double reductionC = payment - newInC;
newPrinC = newPrinC - reductionC;

0
 
appxpeteConnect With a Mentor Commented:
I see a close brace at the end of the code section that defines variable J.  It would appear that the definition is enclosed in braces that make it defined locally to that secion and not visible to the later code.


double newRate = rateValue / 100;
double J = newRate / 12;
//double moInC=(newRate*12)/100;

// to display amount in correct format
DecimalFormat df = new DecimalFormat("$#,###.00");

double mortgage = (Math.pow((1 + J), termValue) - 1)
/ (J * Math.pow((1 + J), termValue));
double payment = amountValue / mortgage; // *Rate Calculation

gui.paymtField.setText("" + df.format(payment));

}
0
 
pgmtklAuthor Commented:
removing that set of braces worked. thanks
0
 
WebstormCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.