/*
   Solve 2nd degree equation.
*/

#include <iostream>   // cin,cout
#include <cmath>      // sqr
using namespace std;

int main()
{
   double a,b,c;

   cout << "Please enter coefficients:\n";
   cout << "a:";
   cin >> a;

   cout << "b:";
   cin >> b;

   cout << "c:";
   cin >> c;

   double D=b*b-4.0*a*c;   // Discriminant

   if (D<0)
         {  // no solution
             cout << "No real solution\n";
         }
   else
         {  // D<0 false => D==0 eller D>0

           if (D>0) // two solutions
             {
               double x1=(-b+sqrt(D))/(2.0*a);
               double x2=(-b-sqrt(D))/(2.0*a);

               cout << "The two solutions are:" << x1 << " " << x2 << "\n";
             }
           else     // D==0 only one solution
             {
               double x1=-b/(2.0*a);
               cout << "The only solution is:" << x1 << "\n";
             }
         }

   return 0;
}

