#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
class MoadeleDaraje2Class
{
	private :
		double delta, x1, x2;
		int CalculateDelta()
		{
			delta = b * b - 4 * a * c;
		}
		void CalculateRoots()
		{
			if(delta > 0)
			{
				x1 = (-b + sqrt(delta))/(2*a);
				x2 = (-b - sqrt(delta))/(2*a);
			}
			else if(delta == 0)
				x1 = -b / (2 * a);
		}
	public :
		double a, b, c;
		int GetNoOfRoots()
		{
			CalculateDelta();
			if(delta > 0) // 2 roots
				return 2;
			else if(delta == 0) //1 root
				return 1;
			else
				return 0; //nothing
		}
		double GetRootNo1()
		{
			CalculateRoots();
			return x1;
		}
		double GetRootNo2()
		{
			CalculateRoots();
			return x2;
		}
};

int main()
{
	MoadeleDaraje2Class A;
	cout << "ax^2 + bx + c " << endl << endl;
	cout << "moadele darage 2 be shekle bala ast, be tartib zaraeb a, b, c ra vared konid." << endl;
	cout << endl << "a = ";
	cin >> A.a;
	cout << endl << "b = ";
	cin >> A.b;
	cout << endl << "c = ";
	cin >> A.c;
	switch (A.GetNoOfRoots())
	{
		case 2 : cout << endl << "tedade rishe ha 2ta ast : x1 = " << A.GetRootNo1() << ", x2 = " << A.GetRootNo2() << endl; break;
		case 1 : cout << endl << "faghat yek rishe darad : x = " << A.GetRootNo1() << endl; break;
		case 0 : cout << endl << "hich rishe nadarad" << endl; break;
	}
	getch();
}

