• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

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");
}
}//*/
0
pgmtkl
Asked:
pgmtkl
  • 3
  • 2
  • 2
2 Solutions
 
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
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
appxpeteCommented:
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
 
WebstormCommented:
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
 
pgmtklAuthor Commented:
removing that set of braces worked. thanks
0
 
WebstormCommented:
:-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now