Files correlati : Ricompilazione Demo : [ ] Commento : Aggiunti i sorgenti per Greenleaf Math Library (gfm.dll) git-svn-id: svn://10.65.10.50/trunk@10079 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			45 lines
		
	
	
		
			793 B
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			793 B
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
#include <stdio.h>
 | 
						|
#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);
 | 
						|
}
 |