This is the program and I have 5 errors that I can't seem to get rid of, it was a Fortran 95 program that I had to translate into C++. could somone please help me.
#include <iostream>
using namespace std;
int main()
{
//Declaration and Intialization
float XL = 0.0;
float XR = 0.0;
float XS = 0.0;
float X = 0.0;
float Y = 0.0;
float YL = 0.0;
float YR = 0.0;
float XB = 0.0;
float XND = 0.0;
float STEPSIZE = 0.0;
float F;
cout<<"What is the left-most interval endpoint?";
cin>>XB;
cout<<"What is the right-most interval endpoint?";
cin>>XND;
cout<<"What is the desired step-size for function evaluation?";
cin>>STEPSIZE;
XL = XB;
do
YL = F(XL);
XR = XL + STEPSIZE;
YR = F(XR);
if(YL*YR > 0)
{
if(XR >= XND) break;
{
XL = XR;
YL = YR;}
}
if (YL*YR == 0)
{
if (YL == 0.0)
{
cout<<"This is a root.";
cout<<XL;
}
if (XR >= XND) break;
XL = XR;
}
else
{
cout<<"This is a root.";
cout<<XR;
if (XR >=XND) break;
XL = XR + STEPSIZE;
}
if (YL*YR < 0)
{
XS =XR;
do
{
X=(XL + XR)/2;
Y = F(X);
if (YL*Y > 0)
{
XL=X;
YL=Y;
}
if (YL*Y == 0)
{
cout<<"This is a root.";
cout<<X;
XR = X;
YR=Y;
}
if (YL*Y < 0)
{
XR = X;
YR = Y;
}
if (XR - XL < 0.00005)
{
cout<<"This interval contains a root.";
cout<< XL,XR;
XL = XS;
}
if (XL >= XND) break;
}
while (XL<XND);
float F;
F = (X*X*X*X - 9*X*X*X - 2*X*X + 120*X - 130);
return F;
}
The errors are:
F:\C ++ Numerical Methods\RF_BETTER.CPP(33) : error C2064: term does not evaluate to a function
F:\C ++ Numerical Methods\RF_BETTER.CPP(35) : error C2061: syntax error : identifier 'XR'
F:\C ++ Numerical Methods\RF_BETTER.CPP(37) : error C2064: term does not evaluate to a function
F:\C ++ Numerical Methods\RF_BETTER.CPP(77) : error C2064: term does not evaluate to a function
F:\C ++ Numerical Methods\RF_BETTER.CPP(127) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
RF_BETTER.OBJ - 5 error(s), 0 warning(s)