Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

//C++ TO JAVA CONVERTER TODO TASK: There are no simple equivalents to function p

ID: 3649766 • Letter: #

Question

//C++ TO JAVA CONVERTER TODO TASK: There are no simple equivalents to function pointers in Java:
double modified_secant_root(double (*f)(double), double xr, double delta, double es)
{
double xrold;
int i;
for (i = 1; i<100; i++)
{
double newxr;
double perturbation;
double ea;
double fxr = f(xr);
perturbation = delta * xr;
newxr = xr - ((compute *fxr)/ (f(xr+compute) - fxr));
ea = (newxr - xr) / newxr;
System.out.printf ("%2d: xr=%f newxr=%f ea=%#2.6g%% ", i, xr, newxr, ea *100);
xr = newxr;
if ((ea < 0 && (-ea) < es) || (ea > 0 && ea < es))
return newxr;
}
return xr;
}

Explanation / Answer

Converts all versions of C/C++ code: C, C++, C++11, Managed C++ (VC++ 2003), and C++/CLI (VC++ 2005 or later) Handles #define, #include, typedef, default parameters, arrays, and more Allows custom replacement of library functions to instance or static methods Allows custom replacement of strings in the final converted code Accurate even with poorly formatted C and C++ code