Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use C++ Language. Your program should test the users input data for !cin.eof() and cin.good(). A single-variable quadratic equation is an algebraic equation of the

Use C++ Language. Your program should test the users input data for !cin.eof() and cin.good().

A single-variable quadratic equation is an algebraic equation of the form ax2+bx+c = 0, where a, b, and c are three fixed coefficients, and x is a variable that can take on different values. The Quadratic.cpp program asks the user to enter three values for the coefficients, and it produces no, one or two real roots as described in the paragraphs below. Your assignment is to modify the Qudratic1.cpp program so that it contains and uses a C++ class for the quadratic formula as described below. For a quadratic expression such as ax2+bx+c, a real root is any double precision number x such that ax2+bx+c = 0. For example, the quadratic expression x2+4x+3 = 0 has one of its real roots at x = -3. Substituting x = -3 into the formula yields the value 0. Its other real root is at x = -1. The equation x2 4x + 4 = 0 has only one root, which is x = 2, and the equation x2+x+1 = 0 has no real roots. There are four rules for finding the real roots of a quadratic expression: (1) Coefficient a must be a non-zero rational number. (2) If a is non-zero and b2 < 4ac, then there are no real roots. (3) If a is non-zero and b2 = 4ac, then there is one real root at x = -b/2a. (4) If a is non-zero, and b2 > 4ac, then there are two real roots which are x = (-b + sqrt (b*b - 4*a*c))/(2*a) and x = (-b - sqrt (b*b - 4*a*c))/(2*a)

where sqrt is the square root function in the cmath library.

Please specify, design, and implement a class that can store and manage information about a quadratic expression. The default constructor should set all three coefficients to zero, and another constructor or method should allow the user to update these coefficients in an object of the class. Also, write a member method that returns the number of the roots of a quadratic expression. This answer could be either 0, 1, or 2. Write other member methods that among them calculate and return the real roots, if any, of the quadratic equation.

Also, please create a main() tester which accepts the three coefficient values from the users keyboard. Assume that your tester will be run on-line, and that it will be started anew for each test run. Also, you will have to prompt the user to enter the coefficients.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Science Project Ideas In Health Care Volume 1

Authors: Zemelak Goraga

1st Edition

B0CPX2RWPF, 979-8223791072

More Books

Students also viewed these Databases questions

Question

7-16 Compare Web 2.0 and Web 3.0.

Answered: 1 week ago