#include<iostream>
#include<cmath>
#include<complex>
using namespace std;

int main() {
	//This program will take a quadratic in the form Ax^2+Bx+c and solve for the roots of the quadratic using the quadratic formula
	//Quad Form: -b+-sqrt((b^2-4ac)/(2a))
	//Working on adding imaginary(i) numbers
	//(2,1) in complex c++ is the same as 2+i in math
	// Lots of help in complex c++ in this thread {http://w...content-available-to-author-only...b.com/software-development/cpp/threads/311699}

	double a, b, c;
	double Sol1, Sol2;
	complex<double> cSol1, cSol2, discr;
	

	cout << "Enter A,B, and C. From the general form of a quadratic. Ax^2+Bx+c";
	cout << "\nEnter A  ";
	cin >> a;
	cout << "\nEnter B  ";
	cin >> b;
	cout << "\nEnter C  ";
	cin >> c;
	
	if (a==0){
	    cout<< "Not a Quadratic\n";
	    }
	    

	else if ((b*b-4*a*c) < 0) {
		cout << "\nImaginary Roots";
		discr =sqrt(complex<double>(b*b-4*a*c));
		complex<double> cSol1= ((-1*b)-discr)/(2*a);
	 	complex<double> cSol2= ((-1*b)+discr)/(2*a);

		cout << "\nThe solutions are x = " << cSol1;
		cout << "\nAnd x = " << cSol2 << endl;
		
		}

	else {

	Sol1=sqrt(pow(b , 2)-(4*a*c))-(b*-1);
	Sol1= (Sol1)/(2*a);
	Sol2=((-1)*sqrt(pow(b, 2)-(4*a*c)))-(b*-1);
	Sol2=(Sol2)/(2*a);

	cout <<"\n The Solutions are x = " << Sol1;
	cout <<"  And x = " << Sol2 << endl;
}

	return 0;
	}