Code:
#include <iostream>
#include <cmath>
using namespace std;
void getData(float &, float &, float &, float &);
double CalcDist(float, float, float, float);
double CalcRadius(float, float, float, float);
double CalcCircum(double, double);
double CalcArea(double, double);
void PrintAll(double, double, double, double);
int main()
{
float x1 = 0;
float x2 = 0;
float y1 = 0;
float y2 = 0;
double distance = 0;
double radius = 0;
double circumfrence = 0;
double area = 0;
const double Pi = 3.1416;
getData(x1, x2, y1, y2);
distance = CalcDist(x1, x2, y1, y2);
radius = CalcRadius(x1, x2, y1, y2);
circumfrence = CalcCircum(Pi, radius);
area = CalcArea(Pi, radius);
PrintAll(distance, radius, circumfrence, area);
return 0;
}
void getData(float &xcord1, float &xcord2, float &ycord1, float &ycord2)
{
cout << "Please enter the x coordinate for the center point " ;
cin >> xcord1;
cout << "Please enter the y coordinate for the center point " ;
cin >> ycord1;
cout << "Please enter the x coordinate for a point on the circle " ;
cin >> xcord2;
cout << "Please enter the y coordinate for a point on the circle " ;
cin >> ycord2;
}
double CalcDist(float xcord1, float xcord2, float ycord1, float ycord2)
{
return sqrt(pow(xcord1 - xcord2, 2) + pow(ycord1 - ycord2, 2));
}
double CalcRadius(float xc1, float xc2, float yc1, float yc2)
{
double Temp = 0;
Temp = CalcDist(xc1, xc2, yc1, yc2);
return Temp;
}
double CalcCircum(double Pie, double rad)
{
return (2* Pie * rad);
}
double CalcArea(double Pie, double rad)
{
return (Pie * pow(rad, 2));
}
void PrintAll(double dis, double rad, double cir, double are)
{
cout << "The distance between the points is :" << dis ;
cout << "The radius of the circle is :" << rad ;
cout << "The circumfrence of the circle is :" << cir ;
cout << "The area of the circle is :" << are ;
}