What data would you put together into a struct so that it would make that program easier to manage and make the data on it easier to manage. C++ #include #include #include //Define constants Pi...


What data would you put together into a struct so that it would make that program easier to manage and make the data on it easier to manage. C++


#include


#include


#include


//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:="">


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=""><>


cout<"\nplease enter="" the="" center="" point="" in="" the="" form="" x="" y:="">


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:="">


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=""><>


cout<"\nplease enter="" the="" point="" on="" the="" circle="" in="" the="" form="" x="" y:="">


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=""><><><><") and=""><><><><><>


cout<"radius:><><>


cout<"area:>


cout<"perimeter:><><>


return 0;


}

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here