Professional Documents
Culture Documents
#include <string>
#include <cmath>
using namespace std;
int main()
{
double a,b,c, discriminant;
char type;
bool loop = true ;
string answer;
while(loop)
{
Get_coefficients( &a, &b, &c ) ;
type = Calc_discriminant( a, b, c, &discriminant) ;
Calc_root( type, a, b, c, discriminant) ;
cout<<"Would you like to coninue? (enter yes or no) : ";
cin>> answer;
if(answer == "yes")
{
loop = true ;
}
else if(answer == "no")
{
loop = false ;
cout<<" Goodbye." << endl;
}
else
{
loop = false;
cout<<"You have entered the wrong input!\n" <<"Goodbye " <<endl;
}
}
return 0;
}
if (check == 'r')
{
cout << "x1 = "<< root_1 <<endl << "x2 = " << root_2 << endl;
}
else if (check == 'i')
{
cout<< "x1 = "<< real <<"+ " << imaginery << "i" <<endl;
cout<< "x2 = "<< real <<"- " << imaginery << "i" <<endl;
}
else
{
cout << "x1 = "<< root_1 <<endl << "x2 = " << root_2 << endl;
}
return 0;
}