n this lab, you will construct a class called QuadraticSolver that will compute the real roots of a  quadratic function (�(�) = ��! + �� + �). The class will implement the following methods. • A default constructor that initializes a legitimate quadratic function. • An overloaded constructor that takes the values of a, b, and c in the function �(�) = ��! + �� + �. This method throws a QuadraticException in the case where the input does not  define a quadratic function. • A method that computes the discriminant (�! − 4��). • Boolean methods determining whether the solutions of the quadratic equation ��! + �� + � = 0 have real or non-real solutions. • Two methods, one for each real root of the equation ��! + �� + � = 0. Each method will throw  a NonRealException when the root is a non-real value. • A toString method that (reasonably) prints the quadratic function. The classes QuadraticException and NonRealException have been provided. Implement  a main method in a separate class to test your implementation. Sample input/output is given below: Run 1 Give me a co-efficient a: 0 Give me a co-efficient b: 1 Give me a co-efficient c: 1 Caught a QuadraticException:: Given input does not define a quadratic equation. Run 2 Give me a co-efficient a: 2 Give me a co-efficient b: 0 Give me a co-efficient c: 0 The equation: (2x^2)  and has real solutions.  Root 1: 0.0  Root 2: 0.0 Run 3 Give me a co-efficient a: 2 Give me a co-efficient b: 8 Give me a co-efficient c: 2 The equation: (2x^2) + (8x) + (2)  and has real solutions.  Root 1: -0.2679491924311228  Root 2: -3.732050807568877 Run 4 Give me a co-efficient a: -3 Give me a co-efficient b: 2 Give me a co-efficient c: -2 Caught a NonRealException: The roots of the equation are non-real

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In this lab, you will construct a class called QuadraticSolver that will compute the real roots of a 
quadratic function (�(�) = ��! + �� + �).
The class will implement the following methods.
• A default constructor that initializes a legitimate quadratic function.
• An overloaded constructor that takes the values of a, b, and c in the function �(�) = ��! +
�� + �. This method throws a QuadraticException in the case where the input does not 
define a quadratic function.
• A method that computes the discriminant (�! − 4��).
• Boolean methods determining whether the solutions of the quadratic equation ��! + �� + � =
0 have real or non-real solutions.
• Two methods, one for each real root of the equation ��! + �� + � = 0. Each method will throw 
a NonRealException when the root is a non-real value.
• A toString method that (reasonably) prints the quadratic function.
The classes QuadraticException and NonRealException have been provided. Implement 
a main method in a separate class to test your implementation. Sample input/output is given below:
Run 1
Give me a co-efficient a: 0
Give me a co-efficient b: 1
Give me a co-efficient c: 1
Caught a QuadraticException:: Given input does not define a quadratic equation.
Run 2
Give me a co-efficient a: 2
Give me a co-efficient b: 0
Give me a co-efficient c: 0
The equation: (2x^2)
 and has real solutions.
 Root 1: 0.0
 Root 2: 0.0
Run 3
Give me a co-efficient a: 2
Give me a co-efficient b: 8
Give me a co-efficient c: 2
The equation: (2x^2) + (8x) + (2)
 and has real solutions.
 Root 1: -0.2679491924311228
 Root 2: -3.732050807568877
Run 4
Give me a co-efficient a: -3
Give me a co-efficient b: 2
Give me a co-efficient c: -2
Caught a NonRealException: The roots of the equation are non-real

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY