Question: Problem 2] Define the class Quadratic that has the following data fields and methods. Data fields: . o Instance data fields: a, b, and c

 Problem 2] Define the class Quadratic that has the following data

Problem 2] Define the class Quadratic that has the following data fields and methods. Data fields: . o Instance data fields: a, b, and c of type double. These variables store the coefficients of a quadratic equation of the form a * x*x+b *x+c. Methods: o An empty no-arg constructor. o A constructor that takes three arguments, sets the instance data fields to the taken arguments. Quadratic(double aVal, double bVal, double cVal) A void method named setA that sets the value of the instance data field a to the value provided as an argument. A void method named setB that sets the value of the instance data field b to the value provided as an argument. A void method named set that sets the value of the instance data field c to the value provided as an argument. void setC(double cValue) { 3 A method that checks whether the equation has two real roots. If vb2 4ac > 0, the equation has two real roots and the method returns true, otherwise it returns false. boolean hasRealRoots() { A method that evaluates the equation at a given point x. The method returns the result of evaluating this equation at a given point x (a *x*x+b*x + c), with x given as an argument. For example, if a = 2, b = 1, and c = -1 and x = 3. the method returns 20 (2*3*3 + 1*3-1 = 20). double evaluate Quadratic(double x) { o O vote

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!