← 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.
Skills to Practice
- Invoke math functions
- Branching with selection statements
Challenge Tasks
- Create a console project named CodeChallenge10Quadratics.
- Complete the folowing tasks:
- Prompt the user to enter the values for variables a, b, and c.
- Calculate the discriminant
- If the discriminant is greater than zero, there are two roots. Calculate both formulas.
- If the discriminant is equal to zero, there is one root. Use either formula.
- If the discriminant is negative, there are no roots. No need to calculate further.
- Output the result(s) to the user.
Sample Output