vinnie wrote:
I'm just trying to calculate the final value, when given a number of
years, an initial amount, and an interest rate, i get the final
amount payed.
Yes. That general description is apparent from the code you posted.
But that's not at all the information Jon asked you to provide.
I did inserted the "return future_value" but it did not work anyway.
It's obvious from the code you posted that the code you posted wasn't
simply copy and pasted from the actual program. The missing return
statement and the mixed naming ("future_value" versus "valore_futuro")
make that clear enough.
So, any comment on the code you posted may or may not actually be
relevant to whatever problem you're actually having. We'd be commenting
on what you posted, not the code you're actually using.
That said, in the code you posted, there is no variable that actually
depends on the iteration of the loop. All that the loop does is keep
calculating the same "alfa" and "valore_futuro" over and over. The
inputs to the "alfa" calculation don't change, and so the inputs for
"valore_futuro" don't change either ("alfa" being the only one modified
within the loop). Thus the calculated value for "valore_futuro" is
exactly the same each time through the loop.
I leave it to the CPAs to decide whether your algorithm, even if
modified so that the code in the loop does useful work, is actually a
proper calculation of "future value". But as a programmer I can tell
you that the loop you posted is useless.
If you want it to do something useful, you need to explain better the
exact calculation you're trying to implement.
And if you want anyone to comment on the code you're _using_ you need to
actually post that code. And for best assistance you need to post code
that is "concise-but-complete", meaning it contains _nothing_ not
directly related to reproducing the problem, but it at the same time is
ready to be compiled as-is, without any additional work on the part of
someone trying to compile it.
This latter is something Jon already asked you once to provide. If you
expect any real help, you need to be willing to work with the people
offering help to provide the details they need to help you.
Pete