hidden error

  • Thread starter Thread starter Vinnie
  • Start date Start date
V

Vinnie

Can anyone tell me why the for cycle does not work? I only get the
multiplication, but the FOR does not start:

protected double CalFutureValue(double initial_value, double
interest_rate, int years)
{
double future_value =0;
double alfa = 0;
for (int i = 1; i <= years; i++)
{
alfa = (initial_value * (interest_rate / 100)) ;
valore_futuro = (alfa + initial_value);
}

}

the fact is that i don't get any error message, it's just not making
the calculation.
Thanks
 
Vinnie said:
Can anyone tell me why the for cycle does not work? I only get the
multiplication, but the FOR does not start:

protected double CalFutureValue(double initial_value, double
interest_rate, int years)
{
double future_value =0;
double alfa = 0;
for (int i = 1; i <= years; i++)
{
alfa = (initial_value * (interest_rate / 100)) ;
valore_futuro = (alfa + initial_value);
}

}

the fact is that i don't get any error message, it's just not making
the calculation.
Thanks

I see no reason why it wouldn't do the calculation. It's hard to tell,
though, as the code isn't the actual code that you are using. You have
edited the code so that it doesn't even compile any more.

What do you do with the value after the loop? There is no return
statement to return the value from the method.
 
I see no reason why it wouldn't do the calculation. It's hard to tell,
though, as the code isn't the actual code that you are using. You have
edited the code so that it doesn't even compile any more.

What do you do with the value after the loop? There is no return
statement to return the value from the method.

I did insert the return statement, but still not working.
I wanna just show on the page with something like this: label2.Text =
future_value.ToString();
 
Vinnie said:
I did insert the return statement, but still not working.
I wanna just show on the page with something like this: label2.Text =
future_value.ToString();

I see no problem with the logic in the code. That's all that I can say
about the code that you posted.

If you want any more help, you have to either post the actual code that
you have problems with, or post a woking example that demonstrates the
problem.
 
Back
Top