Find the roots of Quadratic Equation – Java Program

Quadratic equation is in the form = ax2 + bx + c

Discriminant (d) = b2 – 4ac

Then roots are calculates using the equations below

Root_1 =  (-b + √d)/2a

Root_2 =  (-b – √d)/2a

See the image below

Quadratic Equation-1.png

Java Code:

Output:

Quadratic Equation: +3x^2 -5x -8 = 0, Roots are:(2.6666666666666665, -1.0

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.