Question
The Bold is where the only error is coming up. package quadraticequation; import java.util.Scanner; /** * */ public class QuadraticEquation { public QuadraticEquation(double nextDouble, double
The Bold is where the only error is coming up.
package quadraticequation;
import java.util.Scanner; /** * */ public class QuadraticEquation {
public QuadraticEquation(double nextDouble, double nextDouble1, double nextDouble2) { }
/** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here //Problem 9.10 Quadratic Equation Scanner input = new Scanner(System.in); System.out.print("Enter a, b, c: "); QuadraticEquation quad = new QuadraticEquation(input.nextDouble(), input.nextDouble(), input.nextDouble());
double discriminant = quad.getDiscriminant();
if (discriminant > 0) { System.out.println("root1: " + quad.getRoot1()); System.out.println("root2: " + quad.getRoot2()); } else if (discriminant == 0) { System.out.println("root: " + quad.getRoot1()); } else { System.out.println("The equation has no roots."); } private double a; private double b; private double c;
{ this.a = a; this.b = b; this.c = c; }
public double getA() { return a; }
public double getB() { return b; }
public double getC() { return c; }
public double getDiscriminant() { return (getB() * getB()) - (4 * getA() * getC()); }
public double getRoot1() { if (getDiscriminant()
public double getRoot2() { if (getDiscriminant() 9.10 (Algebra: quadratic equations) Design a class named QuadraticEquation for a quadratic equation ax br c The class contains: 0 Private data fields a, b, and c that represent three coefficients. A constructor with the arguments for a, b, and c. Three getter methods for a, b, and c. A method named getDiscriminant ( ) that returns the discriminant, which is b2-4ac. " The methods named getRoot1) and getRoot2) for returning two roots of the equation and r2- These methods are useful only if the discriminant is nonnegative. Let these methods return O if the discriminant is negative. Draw the UML diagram for the class then implement the class. Write a test program that prompts the user to enter values for a, b, and c and displays the result based on the discriminant. If the discriminant is positive, display the two roots. If the discriminant is 0, display the one root. Otherwise, display "The equation has no roots." See Programming Exercise 3.1 for sample runs
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