Home

Finance Functions:
Making an Investment or Paying a Loan

 

The Payment() function is used to calculate the regular payment of an investment. Its syntax is:

Extended __fastcall Payment(Extended Rate,
                            int NPeriods,
                            constExtended PresentValue,
                            const Extended FutureValue,
                            TPaymentTime PaymentTime);

In the following examples, a customer is applying for a car loan. The car costs $15500. It will be financed at 8.75% for 5 years. The dealer estimates that the car will have a value of $2500 when it is paid off. The dialog box is used to calculate the monthly payment (the Payments edit box) that the customer will make every month:

//---------------------------------------------------------------------------
void __fastcall TForm1::btnCalculateClick(TObject *Sender)
{
	Extended Present, Future, TheRate, Payments, NPeriod;

	Present = StrToFloat(edtLoan->Text);
	Future = StrToFloat(edtFuture->Text);
	TheRate = StrToFloat(edtRate->Text) / 12;
	NPeriod = StrToFloat(edtNPeriods->Text);

	double Rate = TheRate / 100;
	// Apply the function
	Payments = Payment(Rate, NPeriod, -Present,
	Future, ptStartOfPeriod);
	// Display the payments
	edtPayments->Text = FloatToStrF(Payments, ffCurrency, 8, 2);
}
//---------------------------------------------------------------------------
 
Home Copyright 2004 FunctionX, Inc.