#include #include "gm.h" void getdec(char *,DEC *); void main(void); void main() { int nper, nyear, opt, begend; DECP pv, pmt, fv, intr, aintr; DEC *p; printf("Monthly payment computation\n"); getdec("Purchase price: ", pv); getdec("Percentage annual interest rate: ", aintr); printf("Length of loan (years): "); dscanf("%d", &nyear); nper = nyear * 12; ZeroDecimal(fv); DivideDecimalByInt(intr, aintr, 12); opt = GM_PMT; begend = GM_END; p = CompoundInterest(&nper, intr, pv, pmt, fv, begend, opt); if (p) { AbsoluteDecimal(pmt, pmt); dprintf("The monthly payment is %v\n", pmt); } else dprintf("CompoundInterest failed\n"); } void getdec(str, x) char *str; DEC *x; { int i; do { printf("%s", str); i = dscanf("%t", x); } while (i<1); }