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

Goals: Developing problem-solving skills,declaring variables, reading data from

ID: 3617692 • Letter: G

Question

Goals: Developing problem-solving skills,declaring variables, reading data from a file, using loops, andusing functions.

Problem: Write a program that willimplement a function for the quadratic formula to determine bothpossible values of x given input coefficients a, b, and c. Recallthe quadratic formula:

Forax2+bx+c=0        thevalue of x is given by x = -b±b2-4ac/2a   

Your program should read the coefficients a, b, and c from theinput text file provided. Each row of the text file has one set ofcoefficients (a, b, and c in that order) for a single equation.

Each set of coefficients should be passed to your function thatwill carry out the quadratic formula. Your function should computethe two possible values of x for each set of coefficients.

Your program should also implement a second (value-returning)function called “num_positive” that takes the twopossible x values (previously computed by your quadratic formulafunction) as parameters and returns how many of the x values arepositive numbers. For example, if passed the x values 3 and 5, yourfunction should return 2. (Assume that 0 is a positive number forthis function.)

Your main() function should implement a loop that prints outthree things:

Sample output of one loop iteration:

a = 3, b = -2, c = -1

The value of x1 is: 1

The value of x2 is: -0.333333

1 of the x values is/are positive.

The loop in your program should continue to read sets of a, b,and c coefficients from the input file and compute the x valuesuntil it reaches the end of the file. Your functions shouldonly employ pass by reference parameters when necessary. Makesure that you include descriptive comments for your functions aswell the normal introductory comments.

Explanation / Answer

please rate - thanks #include #include #include using namespace std; void result(double,double,double,double&, double &); int num_positive(double,double); int main() {double a,b,c,root1,root2; ifstream input; char filename[30]; coutfilename; input.open(filename);          //open file if(input.fail())            //is it ok?        { couta; while(input)     {input>>b>>c;      result(a,b,c,root1,root2);      cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote