Question
//previous poly code int main( ) { Poly inpoly; //inpoly.>>; cin>>inpoly; for ( int i=0;i inpoly.eval(i); complex c1,c2; float determinant = inpoly.b*inpoly.b - 4*inpoly.a*inpoly.c; double
//previous poly code
int main( )
{
Poly inpoly;
//inpoly.>>;
cin>>inpoly;
for(int i=0;i
inpoly.eval(i);
complex c1,c2;
float determinant = inpoly.b*inpoly.b - 4*inpoly.a*inpoly.c;
double x1,x2,realPart,imaginaryPart;
inpoly.roots(c1,c2);
//cout
if (determinant > 0) {
x1 = (-inpoly.b + sqrt(determinant)) / (2*inpoly.a);
x2 = (-inpoly.b - sqrt(determinant)) / (2*inpoly.a);
cout
cout
cout
}
else if (determinant == 0) {
cout
x1 = (-inpoly.b + sqrt(determinant)) / (2*inpoly.a);
cout
}
else {
realPart = -inpoly.b/(2*inpoly.a);
imaginaryPart =sqrt(-determinant)/(2*inpoly.a);
cout
cout
cout
}
return 0;
}
2) More Polynomial Method:s Extend the Poly class to support the evaluation of quadratic polynomials as follows: 1. Add a member function named eval that takes a single double argument representing the 'x' value and returns the result (type double) of evaluating the polynomial at x. 2. Add a void member function named roots that will take two reference arguments of type Complex (use your Complex class), then compute and provide both roots of a quadratic polynomial object. Recall that the roots are given by the quadratic equation: 2a The expression under the radical is referred to as the discriminant. If the discriminant is negative, the roots must be expressed as imaginary values using Complex numbers as follows: 2a 2a The roots method should first determine if the roots are real or imaginary based on the value of the discriminant. If the roots are real, return them as complex values with the imaginary component set to zero, if the roots are imaginary, return them in complex form using the absolute value of the discriminant. 3 2) More Polynomial Method:s Extend the Poly class to support the evaluation of quadratic polynomials as follows: 1. Add a member function named eval that takes a single double argument representing the 'x' value and returns the result (type double) of evaluating the polynomial at x. 2. Add a void member function named roots that will take two reference arguments of type Complex (use your Complex class), then compute and provide both roots of a quadratic polynomial object. Recall that the roots are given by the quadratic equation: 2a The expression under the radical is referred to as the discriminant. If the discriminant is negative, the roots must be expressed as imaginary values using Complex numbers as follows: 2a 2a The roots method should first determine if the roots are real or imaginary based on the value of the discriminant. If the roots are real, return them as complex values with the imaginary component set to zero, if the roots are imaginary, return them in complex form using the absolute value of the discriminant. 3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started