Assignment (3)

CS1440 Due Friday Set. 8


1.Write an algorithm to solve the following quadratic equation:


y = 6x2+4x+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.

No real solutions

(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.


Your algorithm must ask whether you want to solve another equation and proceed if the answer is yes.