JAVA class:  Main.java, Quadratic.java, TestQuadratic.java Create a class called Quadratic for representing a one-variable quadratic expression of the form: ax2 + bx + c a,b and c here are the coefficients.   The class should contain the following methods: * A constructor that accepts values for a, b, and c. * public double getA() * public double getB() * public double getC()   * public double evaluate (int x)   * will return the value of the expression at point x * public double discriminant() - that will return  (b2 - 4ac) * public boolean isImaginaryRoots() - roots are imaginary if (b2 - 4ac) < 0 * public boolean isRealRoots() - roots are real if (b2 - 4ac) >= 0 // these methods can only be invoked if the roots are not imaginary * public float firstRoot() * public float secondRoot() * public boolean isPerfectSquare(); // If the first and second roots are equal * Try to override the toString methods   * Write a sample main program that will work as shown below. Example output:   coefficient a: 4 coefficient b: 4 coefficient c: 1   Quadratic expression: 4x2 + 4x + 1 The roots are real: x1 = -0.5 ;  x2 = -0.5 It is a perfect square.   Evaluating the expression: Enter x: 2 Result : 25   coefficient a: 2 coefficient b: 5 coefficient c: 10   Quadratic expression: 2x2 + 5x + 10 The roots are imaginary. Evaluating the expression: Enter x: 1 Result : 17   Enter coefficient a: 1 Enter coefficient b: 0 Enter coefficient c: -1   Quadratic expression: x2 + 0x + -1 The roots are real. x1 = -1 ; x = 1 It is not a perfect square. Evaluating the expression: Enter x: 5 Result : 24

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

JAVA
class:  Main.java, Quadratic.java, TestQuadratic.java


Create a class called Quadratic for representing a one-variable quadratic expression of the form:

ax2 + bx + c

a,b and c here are the coefficients.

 

The class should contain the following methods:

* A constructor that accepts values for a, b, and c.

public double getA()

public double getB()

public double getC()

 

public double evaluate (int x)  

* will return the value of the expression at point x

public double discriminant()

that will return  (b2 - 4ac)

public boolean isImaginaryRoots()

- roots are imaginary if (b2 - 4ac) < 0

public boolean isRealRoots()

- roots are real if (b2 - 4ac) >= 0

// these methods can only be invoked if the roots are not imaginary

public float firstRoot()

public float secondRoot()

public boolean isPerfectSquare();

// If the first and second roots are equal

* Try to override the toString methods

 

* Write a sample main program that will work as shown below.

Example output:

 

coefficient a: 4

coefficient b: 4

coefficient c: 1

 

Quadratic expression: 4x2 + 4x + 1

The roots are real: x1 = -0.5 ;  x2 = -0.5

It is a perfect square.

 

Evaluating the expression:

Enter x: 2

Result : 25

 


coefficient a: 2

coefficient b: 5

coefficient c: 10

 

Quadratic expression: 2x2 + 5x + 10

The roots are imaginary.

Evaluating the expression:

Enter x: 1

Result : 17

 


Enter coefficient a: 1

Enter coefficient b: 0

Enter coefficient c: -1

 

Quadratic expression: x2 + 0x + -1

The roots are real. x1 = -1 ; x = 1

It is not a perfect square.

Evaluating the expression:

Enter x: 5

Result : 24

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education