Question: Could you please write this program in c++??: Program 3- Quadratic Equation (Homework) CSCI 259 The two roots of a quadratic equation ax2 + bx
Program 3- Quadratic Equation (Homework) CSCI 259 The two roots of a quadratic equation ax2 + bx + c = 0 can be obtained using the following formula: -b-b2-4ac -b+vb-4ac and r2- b2 - 4ac is called the discriminant of the quadratic equation, and its value determines the number of roots as follows: b2-4ac >0, two real roots: rl and r2 b2-4ac = 0, one real root: r b2-4ac0, no real roots Write a program that prompts the user for coefficients a, b, and c. Based on the discriminant, determine and output the number of real roots and their values, if there are any (you must use an if-statement for this determination) Sample Output (3 examples) Enter the A coefficient: 1 Enter the B coefficient: 3 Enter the C coefficient: 1 1, 0, and -4 coefficients have two real roots r1 =-0.38 r2-2.62 Enter the A coefficient: 1 Enter the B coefficient: 2 Enter the C coefficient: 1, 2, and 1 coefficients have one real root: 1 r=-1.00 Enter the A coefficient: 5 Enter the B coefficient: 5 Enter the C coefficient: 5 5, 5, and 5 coefficients have no real roots
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
