Solving Quadratic Equations

Background

You should be familiar with quadratic equations from your maths lessons - both forming them by expanding double-brackets and solving them in one of three ways:

By far the easiest of these to use in a program is the quadratic formula. It's one of the most "famous" equations in maths - I've seen it in films, music videos and on the back of Asda breakfast cereals!

Quadratic Formula

The values of a, b and c are the coefficient of , the coefficient of x and the constant respectively. For example, with the equation x² + 5x + 6, a would be 1, b would be 5 and c would be 6. If you want to use this as your test case, the solutions should be x = -2 and x = -3.

In this case the ± sign means that you do both the addition and the subtraction - i.e. two separate calculations - to arrive at two answers.

Your Task

Write a program that:

  1. asks the user for the values of a, b and c
  2. determines whether there is a real solution
  3. displays solutions that exist
  4. indicates where there is no real solution
  5. determine whether the two solutions are the same and indicate that there is only one solution

If you are doing A level Maths or you're familiar with complex numbers, then Python can cope with those - you could display the non-real solutions.

Help!