Find the root of a quadratic equation ax² + bx + c using java.

Monica
Mar 19, 2021

The function takes 3 arguments:

  • a as the coefficient of x²
  • b as the coefficient of x
  • c as the constant

Solution

Here we use the quadratic formula

Quadratic formula

First, we allow the user to enter inputs of coefficients of a, b and c using the Scanner class found on the java.util package.

This outputs the following on the terminal

Finally

Easy peesy:). Checkout full code on my github

--

--