In C++ Design a class named QuadraticEquation for a quadratic equation . The class contains: Data fields: a, b, and c that represents three coefficients. A default constructor A constructor for the arguments for a, b, and c. Three get functions for a, b, and c. Three set function for a, b and c. A function named getDiscriminant() that returns the discriminant, which is . Two member functions named getRoot1() and getRoot2() for returning two roots of the equation and These functions are useful only if the discriminant is non-negative. Let these functions return 0 if the discriminant is negative. Implement the class. Write a test program that prompts the user to enter values for , , and , and displays the result based on the discriminant. If the discriminant is positive, display the two roots. If the discriminant is 0, display the one root. Otherwise, display “The equation has no roots”.
In C++ Design a class named QuadraticEquation for a quadratic equation . The class contains: Data fields: a, b, and c that represents three coefficients. A default constructor A constructor for the arguments for a, b, and c. Three get functions for a, b, and c. Three set function for a, b and c. A function named getDiscriminant() that returns the discriminant, which is . Two member functions named getRoot1() and getRoot2() for returning two roots of the equation and These functions are useful only if the discriminant is non-negative. Let these functions return 0 if the discriminant is negative. Implement the class. Write a test program that prompts the user to enter values for , , and , and displays the result based on the discriminant. If the discriminant is positive, display the two roots. If the discriminant is 0, display the one root. Otherwise, display “The equation has no roots”.
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section12.2: Providing Class Conversion Capabilities
Problem 6E
Related questions
Question
In C++
Design a class named QuadraticEquation for a quadratic equation .
The class contains:
- Data fields: a, b, and c that represents three coefficients.
- A default constructor
- A constructor for the arguments for a, b, and c.
- Three get functions for a, b, and c.
- Three set function for a, b and c.
- A function named getDiscriminant() that returns the discriminant, which is .
- Two member functions named getRoot1() and getRoot2() for returning two roots of the equation
and
These functions are useful only if the discriminant is non-negative. Let these functions return 0 if the discriminant is negative.
Implement the class.
Write a test program that prompts the user to enter values for , , and , and displays the result based on the discriminant.
- If the discriminant is positive, display the two roots.
- If the discriminant is 0, display the one root.
- Otherwise, display “The equation has no roots”.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,