CJCoding With Joseph
15free / daySign inCreate account

Quadratic Roots

Three numbers a, b and c are the coefficients of the equation a·x² + b·x + c = 0 (a is not zero). Compute the discriminant b² − 4ac. When it is positive print Two real roots: <r1> and <r2> with the larger root first; when it is zero print One real root: <r>; when it is negative print No real roots. Use Math.sqrt for the square root and the usual formula (−b ± √d) / (2a).

Expected Output:

Two real roots: 2 and 1

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
If Statements
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (clog, fn, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.