Business Functions: |
|
The Double Declining Balance is a technique used to calculate the depreciating value of an asset. The function used to perform this calculation is the DoubleDecliningBalance() and its syntax is: Extended __fastcall DoubleDecliningBalance(Extended Cost, Extended Salvage, int Life, int Period); The first parameter, Cost, represents the initial value of the item. The Salvage parameter is the estimated value of the asset when it will have lost all its productive value. The Cost and the Salvage values must be given in a monetary value. The value of Life is the length of the lifetime of the item; this could be the number of months for a car or the number of years for a house, for example. The Period is a factor for which the depreciation is calculated. For the Double Declining Balance, this Period argument is usually 2. In the following example, a form is equipped with five Edit controls named edtCost, edtSalvage, edtLife, edtPeriod, and edtDepreciation. After entering the necessay values and pressing Enter, the OnClick event of the Calculate button retrieves the values and calls the DoubleDecliningBalnace() function to calculate the Depreciation and display it the appropriate edit box: //--------------------------------------------------------------------------- #include <vcl.h> #include <math.hpp> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::btnCalculateClick(TObject *Sender) { Extended Cost = StrToFloat(edtCost->Text); Extended Salvage = StrToFloat(edtSalvage->Text); Integer Life = StrToInt(edtLife->Text); Integer Period = StrToInt(edtPeriod->Text); Extended Depreciation = DoubleDecliningBalance(Cost, Salvage, Life, Period); edtDepreciation->Text = FloatToStr(Depreciation); } //--------------------------------------------------------------------------- void __fastcall TForm1::btnExitClick(TObject *Sender) { Close(); } //---------------------------------------------------------------------------
|
Home | Copyright © 2004-2016, FunctionX, Inc. | |