← Back

Code Challenge 10 - Quadratic Equation


Introduction

The quadratic equation is a fundamental algebra formula for discovering roots of a parabola. This equation seems intimidating to calculate, but the key to it is to first calculate the discriminant, or b squared - 4ac. Depending on the result, you either need to use both formulas, just one of them, or neither of them.

Quadratic Equation

Skills to Practice

Challenge Tasks

  1. Create a console project named CodeChallenge10Quadratics.
  2. Complete the folowing tasks:
    1. Prompt the user to enter the values for variables a, b, and c.
    2. Calculate the discriminant
    3. If the discriminant is greater than zero, there are two roots. Calculate both formulas.
    4. If the discriminant is equal to zero, there is one root. Use either formula.
    5. If the discriminant is negative, there are no roots. No need to calculate further.
    6. Output the result(s) to the user.

Sample Output