//"If" staements that returns the appropriate number of roots
if((fabs(coefA-0.0)<0.00001)&&(abs(coefB-0.0)<0.00001))
{
if((fabs(coefA-0.0)<0.00001)&&(abs(coefB-0.0)<0.00001))
{
cout<<"There are infinite number of possible solutions";
}
else
{
cout<<"There are no real roots.";
}
}
else if (fabs(coefA-0)<0.00001)
{
cout<<"There is one real root = "<<fixed<<setprecision(2)<<x3;
}
else if(fabs(x4-0.0)<0.00001)
{
cout<<"There are no real roots.";
}
else if(fabs(x1-x2)<0.00001)
{
cout<<"There is one double real root, root1 = "<<fixed<<setprecision(2)<<x1;
}
else
{
cout<<"There are two real roots, root 1 = "<<fixed<<setprecision(2)<<x1<<" root2 = "<<x2;
}
return 0;
}
The problem o have is when i input values where x4coefB*coefB-4*coefA*coefC would = some negative vale, the program would always skip:
else if(fabs(x4-0.0)<0.00001)
{
cout<<"There are no real roots.";
}
even though x4 is <0.0.
I can't see where i went wrong,any hints?