Now, you will add a few methods to your QuadraticEquationclass to extend its functionality. Starting with your solution to th

Now, you will add a few methods to your QuadraticEquationclass to extend its functionality. Starting with your solution to the previous task, now add the methods below: A method named getDiscriminant() which will be used to calculate the discriminant of an equation. The discriminant is b^2 – 4ac. Two methods named getRoot1() and getRoot2()the returns the two real solutions of an equation if the discriminant is positive. If the discriminant is negative, returns 0. A method named hasSolution() which returns true if the discriminant is positive or false otherwise. A toString() method that returns a string describing the object. This method returns No real solutions if the discriminant is negative. Write the QuadraticEquation class in the answer box below. (Note: you must submit the entire class definition. For example: Test Result =new QuadraticEquation (1, -4, 4); QuadraticEquation quad root1=2.00, root2=2.00 System.out.print1n(quad);



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *