Mortgage calculations.

Anyone have code for a mortgage calculator?
it should be able to do things like work out repayments if you input an interest rate, time period & amount.. and do table as well as decreasing loans (preferably).  + work out how much you can borrow based on income level.

Thanks for any help.
Who is Participating?
kjtengConnect With a Mentor Commented:
The Delphi math unit is also download from:

Take a look at You can download a late beta of Mortgage Planner from here. Its developed in Delphi... It will do all that you request in your question.

Give it a go and tell me what you think of it!

Of course if you are looking for code to integrate into another app then this won't help an awful lot...



delphiexpertAuthor Commented:
Yes I am actually looking for code for an app... so no, it won't help much.
But thanks anyway :)
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.

There is a math.pas file in delphi\source\rtl\sys directory which consist the code for some command financial functions including:

function Payment(Rate: Extended; NPeriods: Integer;  PresentValue, FutureValue: Extended; PaymentTime: TPaymentTime): Extended;

function PeriodPayment(Rate: Extended; Period, NPeriods: Integer;  PresentValue, FutureValue: Extended; PaymentTime: TPaymentTime): Extended;

function PresentValue(Rate: Extended; NPeriods: Integer;  Payment, FutureValue: Extended; PaymentTime: TPaymentTime): Extended;

Let me know if this helps
delphiexpertAuthor Commented:
Looks promising.. however I don't have this math unit.  I've only got the standard version of Delphi 3, I guess it doesn't come with this version.
give me your email address and I will send a copy to you
delphiexpertAuthor Commented:
Thanks, send it to & I'll take a look at it.
delphiexpertAuthor Commented:
Oh, don't bother - that URL will do nicely (when I loaded the page it didnt have the URL there :)
I'll take a look at it and see if it's suitable.  Thanks.

delphiexpertAuthor Commented:
OK call me stupid, but how do I use the routines to work out (for example) this:

Loan of $350,000 at an interest rate of 7%, over 25 years.
I need to know the payment for each period, ie its a table loan.
remember to add math to your uses clause

procedure TForm1.Button1Click(Sender: TObject);
var NPeriods: Integer;
  ee, Rate, PresentValue, FutureValue: Extended; PaymentTime: TPaymentTime;
//  function Payment(Rate: Extended; NPeriods: Integer;
//  PresentValue, FutureValue: Extended; PaymentTime: TPaymentTime): Extended;
  nPeriods := 25 * 12; // 25 * 12 months
  Rate := 0.07/12;   // interest per month
  PresentValue := 350000;
  FutureValue := 0;
  PaymentTime := ptEndOfPeriod; // pay at end of each month
  ee := Payment(Rate, NPeriods, PresentValue, FutureValue, PaymentTime);

Your should get 2473.73
delphiexpertAuthor Commented:
OK, basically thats how I had it, except for the ending value.  Why is it 0, and not something else (the starting value for example)?
Ending value = 0 mean by the end of  the 25 year the loan balance is 0.

If you are using this function for sinking fund investment, annuity or other similar computation, then the EndingValue = the money you would get back at the end of the investment period.

Hope this help
delphiexpertAuthor Commented:
Duh.  How stupid of me :)

Thanks for that, have the points, you deserved them.
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.