Question: Write a method called printQuadratic that solves quadratic equations and prints their roots. (Note: Not return, print!) Recall that a quadratic equation is a polynomial
Write a method called printQuadratic that solves quadratic equations and prints their roots. (Note: Not return, print!) Recall that a quadratic equation is a polynomial equation in terms of a, b and c in the form ax^2+bx+c=0a x 2 + b x + c = 0. The formula for solving a quadratic is x=\frac{-b\pm\sqrt{b^2-4ac}}{2a\:}x = b b 2 4 a c 2 a Your method should accept the coefficients a, b, and c as parameters and should print the 2 roots of the equation. For this assignment you may assume that the equation has two real roots, though mathematically this is not always the case. Your main program should then test your method with the following two examples. For LaTeX: x^{2\:}-7x+12x 2 7 x + 12 it should print out LaTeX: x=4,\:x\:=\:3x = 4 , x = 3 For LaTeX: 2x^2+6x\:+\:4\:=\:02 x 2 + 6 x + 4 = 0 it should print out LaTeX: x=-2,\:x\:=\:-1 JAVA PROGRAMMING CS141
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
