Use a for loop to enter exactly three sets of coefficients asdesired from a file
ID: 3617687 • Letter: U
Question
Use a for loop to enter exactly three sets of coefficients asdesired from a file. The name of the file should be enteredfrom the keyboard in the main function. Output should go tothe screen. The following functions should be called from yourmain program:
getCoefficients: {Reads, and returns the coefficients of the quadratic equationusing reference parameters. The input file should be passed asa parameter.}
echoEquation: {Displays the quadratic equation with the coefficients echoed. Usethe form
ax^2 + (b)x + (c) = 0 }
error: {When a = b = 0 the display the error message: "No linear orquadratic equation is formed."}
linear: {Computes and displays the one root of alinear equation.}
complex: {Roots exist, but are not real. Print themessage "Roots are not real."}
realRoots: {Computes and displays real roots.}
Test case input file:
1 2 3
5 6 1
0 3 6
Test case screen output:
COMPUTE THE REAL ROOT(S) OF A QUADRATIC OR A LINEAR EQUATION
Enter the name of the input file e:in6.txt
Equation 1.00x^2 + (2.00)x + (3.00) = 0
Roots are not real.
Equation 5.00x^2 + (6.00)x + (1.00) = 0
Roots are -0.20 and -1.00.
Equation 0.00x^2 + (3.00)x + (6.00) = 0
Root is -2.00.
Programmer:
Explanation / Answer
please rate - thanks #include #include #include using namespace std; void showOpening(); voidgetCoefficients(ifstream&,double&,double&,double&); void echoEquation(double,double,double); void error(); void linear(double,double); void complex(); void realroots(double,double,double); int main() {double a,b,c; double discriminant; int i; ifstream in; ofstream out; char filename[30]; coutfilename; in.open(filename); if(in.fail()) { coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.