Question
Please help me correct my code with c++ the following is my code and the things i need to solve thank you very much! #include
Please help me correct my code with c++ the following is my code and the things i need to solve thank you very much!
#include
int main() { double a,b,c; double root1,root2; double x,y; cin >> a; cin >> b; cin >> c; double discr = (b * b) - 4.0 * a * c; double res = sqrt (discr); root1 = (- b + res) / 2.0 * a; root2 = (- b - res) / 2.0 * a; if (discr root2) { cout root1) { cout
cout
Quadratic Formula Input: from the user Output: standard output Write a program that will calculate both roots of a quadratic equation. The program should ask the user to input a, b, and c and then write both roots to standard output (the screen). Your program should print the roots ordered from least to greatest. If the quadratic equation has a negative discriminant your program should output "NO REAL ROOTS". If the two roots are the same only report one root. ar? +br +c=0 -b r =- b2 - 4ac 2a Sample Input Sample Output 1, -3, -10 -2.00 5.00 3, 6,3 - 1.00 2.-2, -12 -2.00 3.00 3.-2, 20 NO REAL ROOTS Note: Round all output to 2 decimal places. Also report the vertex of the parabola. STUDENT OUTPUT: SULUTTUN UUTPUT: Pass Documentation Check: prog7. cpp -2.00 5.00 |-2.00 5.00 ***Start extra credit *** *** Start Extra Credit *** vertex = (1. 50, -12. 25) ***End extra credit*** Vertex = (1.50, -12.25) *** End Extra Credit *** -9.00 ***Start extra credit *** |-1.00 vertex = (-1.00, 0.00) ***End extra credit*** *** Start Extra Credit *** Vertex = (-1.00, 0.00) 1-8.00 12.00 ***Start extra credit *** *** End Extra Credit *** vertex = (0.50, -12. 50) ***End extra credit*** ||-2.00No Real Roots***Start extra credit *** 3.00 *** Start Extra Credit ***| vertex = (0.33, 19.67) ***End extra credit***
Vertex = (0.50, -12.50) *** End Extra Credit *** FAIL - Quadratic Formula FAIL - Extra Credit NO REAL ROOTS *** Start Extra Credit ***|| Vertex = (0.33, 19.67)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started