CS1440 – Due Friday Sept. 15
1.Write a C++ code to solve the following quadratic equations:
y = 6x2+4x+3
y = x2+4x+24
y = -4x2-2x-3
The solution to a 2nd order quadratic equation y = ax2+bx+c is:
In our case, a = 6, b = 4, and c=3.
This equation can have one of the following three solutions depending on the value of:
b2 – 4ac. Here are the possibilities:
If b2 – 4ac> 0, i.e., b2 > 4ac then we have two solutions, and
If b2 – 4ac= 0, i.e., b2 = 4ac then we have only one solution, and
If b2 – 4ac< 0, i.e., b2 < 4ac then there is no real solution.
(Actually, there are two imaginary solutions, but for now we assume no solution)
Your algorithm must consider all these details and be able to solve all possible cases and print a warning for cases that is unable to solve.
Sample in put:
This program solves the quadratic equation:
For this case, a = ?, b = ?, c = ?, solution(s) are: