Quadratic Roots
hardQuestion 249Three 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, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
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.