Subscribe:

Sunday, January 1, 2012

Home
Finance Functions:
The Future Value of an Investment

 
The FutureValue() function is used to calculate the future value of an investment. The syntax of this function is:
Extended __fastcall FutureValue(Extended Rate,
                                int NPeriods,
                                Extended Payment,
                                Extended PresentValue,
                                TPaymentTime PaymentTime);
Here is an example:





//---------------------------------------------------------------------------
void __fastcall TForm1::btnCalculateClick(TObject *Sender)
{
 Extended Present, Future, Payment, TheRate;
 int Period;

 Present = StrToFloat(edtPresent->Text);
 Payment = StrToFloat(edtPayment->Text);
 Period = StrToInt(edtPeriod->Text);
 TheRate = StrToFloat(edtRate->Text) / 12;
 double Rate = TheRate /100;
 Future = FutureValue(Rate, Period, Payment, Present, ptEndOfPeriod);

 edtFuture->Text = FloatToStrF(Future, ffCurrency, 8, 2);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnExitClick(TObject *Sender)
{
 Close();
}
//---------------------------------------------------------------------------
 
Home
Finance Functions:
The Number of Periods of an Investment

 
The NumberOfPeriods() function calculates the number of periodic payments of an investment. Its syntax is:
Extended __fastcall PeriodPayment(constExtended Rate,
                                  int Period,
                                  int NPeriods,
                                  const Extended PresentValue,
                                  const Extended FutureValue,
                                  TPaymentTime PaymentTime);
Here is an example:




//---------------------------------------------------------------------------
void __fastcall TForm1::btnCalculateClick(TObject *Sender)
{
 Extended Present, Future, TheRate, Payments, NPeriod;
 
 Present = StrToFloat(edtLoan->Text);
 Future = StrToFloat(edtFuture->Text);
 Payments = StrToFloat(edtPayments->Text);
 TheRate = StrToFloat(edtRate->Text) / 12;
 
 double Rate = TheRate / 100;
 // Apply the function
 NPeriod = NumberOfPeriods(Rate, -Payments, -Present,
 Future, ptStartOfPeriod);
 // Since the number of periods is really an integer, find its ceiling
 Extended Actual = Ceil(NPeriod);
 // Display the number of periods
 edtNPeriods->Text = FloatToStr(Actual);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnExitClick(TObject *Sender)
{
 PostQuitMessage(0);
}
//---------------------------------------------------------------------------
 

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
Finance Functions:
The Amount Paid as Principal

 
While the InterestPayment() function calculates the amount paid as interest for a loan, the PeriodPayment() function calculates the actual amount that applies to the balance of the loan. This is referred to as the principal. Its syntax is:
Extended __fastcall PeriodPayment(constExtended Rate,
                                  int Period,
                                  int NPeriods,
                                  const Extended PresentValue,
                                  const Extended FutureValue,
                                  TPaymentTime PaymentTime);
Here is an example:




//---------------------------------------------------------------------------
void __fastcall TForm1::btnCalculateClick(TObject *Sender)
{
 Extended Present, Future, TheRate, PPayment;
 int Periods, NPeriod;
 
 Present = StrToFloat(edtLoan->Text);
 Future = StrToFloat(edtFuture->Text);
 TheRate = StrToFloat(edtRate->Text) / 12;
 Periods = StrToInt(edtPeriod->Text);
 NPeriod = StrToInt(edtNPeriods->Text);
 double Rate = TheRate / 100;
 
 // Apply the function
 PPayment = PeriodPayment(Rate, Periods, NPeriod, -Present, Future, ptStartOfPeriod);
 // Display the payment
 edtPPMT->Text = FloatToStrF(PPayment, ffCurrency, 8, 2);
}
//---------------------------------------------------------------------------

0 comments:

Post a Comment