Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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
Check Mark
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education