Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Financial Calcs
Message
 
 
À
04/12/2001 10:46:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00588773
Message ID:
00589668
Vues:
30
>Helo,
>I need to know the interest rate

Given the amount borrowed(principal), the monthly payment,the number of months for repayment try this function
FUNCTION getInterest
LPARAMETERS pn_principal,pn_payamount,pn_paynumber
LOCAL iHigh, iLow, i

*!*  iHigh and iLow represent the range the intetrest rate will be in

iHigh = 100 && Impossbly high interest rate - the upper bracket
iLow = 0 && Impossbly high interest rate - the upper bracket
iTolerance = 0.00000000001 
DO WHILE .t.
	iGuess = (iHigh + iLow)/2
	pn_calc = getRate(pn_principal,iGuess,pn_paynumber)
	compare = pn_calc / pn_payamount
	DO CASE
		CASE compare > (1 + iTolerance) && we are too high 
			iHigh = iGuess
		CASE compare < (1 - iTolerance) && we are too low 
			iLow = iGuess
		OTHERWISE  && we are with tol\erance
			EXIT
	ENDCASE

ENDDO

RETURN TRANSFORM(iGuess ) + ' %'

FUNCTION getRate
LPARAMETERS pn_principal,pn_i,pn_paynumber)
LOCAL iRatio
pn_i = pn_i / 1200
iRatio = (1 + pn_i)^pn_paynumber
RETURN pn_principal* pn_i * (iRatio / (iRatio -1))
This will retrun the APR.
Ken Wardwell
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform