//Define constants Pi
#define PI 3.14
using namespace std;
//Define a function to calculate the radius
double calculateRadius(int x1,int y1,int x2,int y2)
{
//Compute radius
double radius = sqrt(pow(x2-x1, 2) + pow((y2-y1), 2));
//Return radius to calling function
return radius;
}
//Define a function to calculate Area
double calculateArea(double radius)
{
//Return area to calling function
return PI * radius * radius;
}
//Define a function to calculate perimeter
double calculatePeriemeter(double radius)
{
//Return perimeter to calling function
return 2*PI*radius;
}
int main()
{
//Variables declaration
int x1, y1, x2, y2;
double radius, area, perimeter;
cout<"\nplease enter="" the="" center="" point="" in="" the="" form="" x="" y:="">"\nplease>
cin>>x1>>y1;
while(1)
{
if(cin.fail())
{
cin.clear();
cin.ignore(numeric_limits::max(),'\n');
cout<"you entered="" something="" that="" is="" not="" a="" number.="" please="" try="">"you><>
cout<"\nplease enter="" the="" center="" point="" in="" the="" form="" x="" y:="">"\nplease>
cin>>x1>>y1;
}
if(!cin.fail())
break;
}
//Prompt the user to enter the point on the circle in the form x y
cout<"please enter="" the="" point="" on="" the="" circle="" in="" the="" form="" x="" y:="">"please>
cin>>x2>>y2;
while(1)
{
if(cin.fail())
{
cin.clear();
cin.ignore(numeric_limits::max(),'\n');
cout<"you entered="" something="" that="" is="" not="" a="" number.="" please="" try="">"you><>
cout<"\nplease enter="" the="" point="" on="" the="" circle="" in="" the="" form="" x="" y:="">"\nplease>
cin>>x2>>y2;
}
if(!cin.fail())
break;
}
//call to functions and store the return values to variables
radius = calculateRadius(x1, y1, x2, y2);
area = calculateArea(radius);
perimeter = calculatePeriemeter(radius);
//display the outputs
cout<"here is="" the="" information="" for="" the="" circle="" formed="" from="">"here><><><><") and="">")><><><><><>
cout<"radius:>"radius:><><>
cout<"area:>"area:>
cout<"perimeter:>"perimeter:><><>
return 0;
}