#include <cstdlib>
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
char ulang;
double A,B,C,D, hasil1,hasil2,;
cout<<“===Akar persamaan Kuadrat (D = B2 – 4AC) == “<<endl;
cout<<“==================================”<<endl;
do
{
A=0;
B=0;
C=0;
cout<<“A:”;
cin>>A;
cout<<“B:”;
cin>>B;
cout<<“C:”;
cin>>C;
D=(B*B)-(4*A*C);
cout<<A <<endl;
cout<<B <<endl;
cout<<C <<endl;
cout<<D <<endl;
if (D > 0)
{
hasil1=-B+sqrt(D)/(2*A);
hasil2=-B-sqrt(D)/(2*A);
cout<<“Ini merupakan 2 Akar yang berbeda : “<<endl;
cout<< “x1=” ;
cout<<hasil1 <<endl;
cout<< “x2=” <<hasil2 <<endl;
}
else if (D==0) {
hasil1=-B/(2*A);
hasil2=hasil1;
cout<<“Ini merupakan 2 Akar kembar : “<<endl;
cout<<“x1=”<<hasil1 <<endl;
cout<<“X2=”<<hasil2 <<endl;
}
else
{
hasil1=-B/(2*A);
hasil2=sqrt(fabs(D))/(2*A);
cout<<“Ini merupakan Akar Imaginer: “<<endl;
cout<<“x1=”<<hasil1<<“+”<<hasil2 <<endl;
cout<<“x2=”<<hasil1<<“-“<<hasil2 <<endl;
}
cout<<“===============================”<<endl;
cout<<“Ulangi penghitungan persamaan kuadrat dengan rumus (D = B2 – 4AC) <y/t> ? “;
cin>>ulang;
} while(ulang==’y’);
return 0;
}