campo-sirio/gfm/demo19.c

47 lines
859 B
C
Raw Normal View History

#include <stdio.h>
#include "gm.h"
void getdec(char *,DEC *);
void main(void);
void main()
{
DEC book[1], salv[1], partial[1];
DEC *depr[50], *remval[50];
int life, i;
printf("Sum of years digits depreciation\n");
getdec("Book value: ", book);
getdec("Salvage value: ", salv);
printf("Lifetime of asset (years): ");
dscanf("%d", &life);
ZeroDecimal(partial);
AllocateDecimalArray(depr, life+1);
AllocateDecimalArray(remval, life+1);
DepreciateSumOfYearsTable(depr, remval, book,
salv, life, partial);
printf("%20s%20s%20s\n", "Year #",
"Depreciation", "Remaining Value");
for (i=1; i<=life; i++)
dprintf("%20d%20v%20v\n", i,
depr[i], remval[i]);
FreeDecimalArray(depr);
FreeDecimalArray(remval);
}
void getdec(str, x)
char *str;
DEC *x;
{
int i;
do {
printf("%s", str);
i = dscanf("%t", x);
} while (i<1);
}