Quadratic Root Solver For a general quadratic equation y = ax? + bx + c, the roots can be classified into three categories depending upon the value of the discriminant which is given by b2 - 4ac...


Quadratic Root Solver<br>For a general quadratic equation y = ax? + bx + c, the roots can be classified into<br>three categories depending upon the value of the discriminant which is given by<br>b2 - 4ac<br>First, if the discriminant is equal to 0, there is only one real root. Then, if the discriminant<br>is a positive value, there are two roots which are real and unequal. The roots can be<br>computed as follows:<br>-b+ Vb? – 4ac<br>2a<br>Further, if the discriminant is a negative value, then there are two imaginary roots. In<br>this case, the roots are given by<br>b<br>ь? - 4ас<br>2a<br>2a<br>Programming tasks:<br>A text file, coeff.txt has the following information:<br>coeff.txt<br>3<br>4<br>4<br>4<br>1<br>4<br>Each line represents the values of a, b and c, for a quadratic equation. Write a program<br>that read these coefficient values, calculate the roots of each quadratic equation, and display<br>the results. Your program should perform the following tasks:<br>• Check if the file is successfully opened before reading<br>• Use loop to read the file from main function<br>• Use programmer-defined function named calcRoots () to calculate the roots<br>• Display the type of roots and the root(s) for each equation to console screen.<br>Format the output to be displayed in floating point numbers, which set to two (2)<br>decimal places of precision.<br>•<br>• Display a message

Extracted text: Quadratic Root Solver For a general quadratic equation y = ax? + bx + c, the roots can be classified into three categories depending upon the value of the discriminant which is given by b2 - 4ac First, if the discriminant is equal to 0, there is only one real root. Then, if the discriminant is a positive value, there are two roots which are real and unequal. The roots can be computed as follows: -b+ Vb? – 4ac 2a Further, if the discriminant is a negative value, then there are two imaginary roots. In this case, the roots are given by b ь? - 4ас 2a 2a Programming tasks: A text file, coeff.txt has the following information: coeff.txt 3 4 4 4 1 4 Each line represents the values of a, b and c, for a quadratic equation. Write a program that read these coefficient values, calculate the roots of each quadratic equation, and display the results. Your program should perform the following tasks: • Check if the file is successfully opened before reading • Use loop to read the file from main function • Use programmer-defined function named calcRoots () to calculate the roots • Display the type of roots and the root(s) for each equation to console screen. Format the output to be displayed in floating point numbers, which set to two (2) decimal places of precision. • • Display a message "There is no solution – not a quadratic" if a equal to 0.

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here