Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Financial Calcs
Message
 
 
To
04/12/2001 10:46:37
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00588773
Message ID:
00589668
Views:
29
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform