The calculation is off".
Perchance is this because you are using single, double, or real for your decimals and getting floating point errors?
Delphi is *NOT* the language suited to do any kind of accurate floating point math due to the lack of fixed point precision integer math in decimal types.
But it can be done, though:
1) Use currency types if you don't need any precision beyond 4 places.
2) You have to be really careful regarding your results. My tip in having done a program with a large amount of these calculations myself is to stick a "write" with the results of each calculation and step through each calculation with your pen and paper. Any discrepancy requires an adjustment, whether you have the math right or not.
You have a hard row ahead of you to get this done and get it right. The before mentioned program I did took about 100000% more effort than I figured it would going into it - actually I ended up writing an fixed point integer math routine to handle what I needed before I was able to tweak the program to work using native Delphi.
If it helps you, here's the Delphized version of the code necessary to calculate the monthly payment given the loan amount, APR, and periods in the loan (that should be step 1 anyhow):
Code:
function power(x, y: double): double;
begin
power := exp(y*ln(x));
end;
apr := t/100/12;
loan_payment := loan_amount/((1-(1/power(1+apr,number_periods)))/apr);