can anyone write this using recursion (java)

Status
You're currently viewing only happyhippie's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

happyhippie

Seniorius Lurkius
8
JAVA
public double BisectPra()
{
double TOL = 0.0001;
int ii = 0;

double min = (CO.calcIndPrAO (isFemale));


double max = (VR.calcIndPsf (isFemale));


double left;
double mid;

CO.calcIndCOmax(isFemale);
CO.calcIndK(isFemale);
VR.calcIndRvr(isFemale);

while( Math.abs(max - min) > TOL )
{

left = (CO.calcCardOut(min) - VR.calcVenReturn(min));
midPra = (min + max) / 2;
mid = (CO.calcCardOut(midPra) - VR.calcVenReturn(midPra));

if(( left * mid ) < 0 )
{
max = midPra;
ii++;
}

else
{
min = midPra;
ii++;
}

}

if(ii>=100000)
{
midPra = -1;
}

return midPra;


}
 

happyhippie

Seniorius Lurkius
8
code:<HR>
Code:
public double BisectPra()
{
	double TOL = 0.0001; 
	int ii = 0; 
	double min = (CO.calcIndPrAO (isFemale)); <P>
	double max = (VR.calcIndPsf (isFemale)); <P>
	double left; 
	double mid; <P>	CO.calcIndCOmax(isFemale);
	CO.calcIndK(isFemale);
	VR.calcIndRvr(isFemale);<P>	while( Math.abs(max - min) > TOL ) 
	{ <P>	left = (CO.calcCardOut(min) - VR.calcVenReturn(min));
	midPra = (min + max) / 2;
	mid = (CO.calcCardOut(midPra) - VR.calcVenReturn(midPra));<P>		if(( left * mid ) < 0 )
		{
			max = midPra;
			ii++;
		}<P>		else
		{
			min = midPra;
			ii++;
		} //end if/else<P>	} //end while<P>	if(ii>=100000) 
	{
	midPra = -1; 
	} //end if<P>	return midPra;<P>
}end method
 
Status
You're currently viewing only happyhippie's posts. Click here to go back to viewing the entire thread.
Not open for further replies.