Design a class named QuadraticEquation for solving a quadratic equation which is of the form ax²+bx+c=0.
Design a class named QuadraticEquation for solving a quadratic equation which is of the form ax²+bx+c=0.
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...
Related questions
Question
Please solve it in Java...

Transcribed Image Text:Design a class named QuadraticEquation for solving a quadratic equation which is
of the form ax²+bx+c=0.
QuadraticEquation
- a: double
- b: double
- c: double
+ QuadraticEquation(a: double, b: double, c: double)
- getDiscriminant(): double
+ evaluateDiscriminant(): void
+ getRoot1(): double
+ getRoot2(0: double
+ toString(): String
The class should contain:
Private data fields a , b , and c that represent three coefficients.
• A single constructor for the arguments for a , b, and c.
A private method named getDiscriminant() that returns the discriminant,
which is the value of b?-4 ac.
A public method named evaluateDiscriminant() which prints out the
following information using the value obtained from getDiscriminant():
o getDiscriminant() > 0, "Two distinct solutions"
getDiscriminant()
o getDiscriminant() < 0, “No real solutions"
The public methods named getRoot1() and getRoot2() return the two
roots of the equation. They return the following, respectively:
= 0, "One unique solution"
-b + Vb - 4ac
-b –
VB - 4ac
and r2 =
2a
2a
However, if no real solutions exist, print out the message "Not possible to
calculate solutions since discriminant is negative". You
may have to return an arbitrary value in this case.
The toString() method returns the details in the following tabular format:
Faculty: SAS3
CSE215L
1
Coefficient | Value
| value of a upto 3 decimal places
a
b
| value of b upto 3 decimal places
| value of c upto 3 decimal places
In your driver class,
construct three objects of QuadraticEquation. Use Scanner class to get
the values of the coefficients for each object.
Call the evaluateDiscriminant() method on each of the objects.
Then, call the getRoot1() and getRoot2() methods on each of the
objects and display the results.
||
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 3 steps with 1 images

Recommended textbooks for you

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY