home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
rettig.zip
/
TRSOURCE.EXE
/
DEPVALSL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-22
|
1KB
|
45 lines
/*********
*
* DEPVALSL.C
*
* by Ralph Davis
* modified by Tom Rettig
*
* Placed in the public domain by Tom Rettig Associates, 10/22/1990.
*
*********/
/* DEPVALSL: Depreciated value by straight-line method
Computes current value of an asset by
straight-line method.
SYNTAX: DEPVALSL(purchase, resale, total periods,
periods to date)
where purchase = initial purchase price
resale = anticipated resale value
total periods = total time of service
periods to date = time periods to be calculated
RETURNS; current value
*/
#include "trlib.h"
TRTYPE depvalsl()
{
if ( PCOUNT==4 && ISNUM(1) && ISNUM(2) && ISNUM(3) && ISNUM(4) )
{
double purchase = _parnd(1);
double resale = _parnd(2);
int totper = (int)_parnd(3);
int periods = (int)_parnd(4);
_retnd((periods >= totper ? 0.0 :
purchase - periods * ((purchase-resale) / totper)));
}
else
_retnd( (double)ERROR );
}