Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started