ill show the problem in the book first then ill tell you what i know.
___________________________________________________________________________
Then following formula gives the distance between two points (x1,y1) and (x2,y2) in the Cartesian plane: √ (x2-x1)^2 + (y2-y1)^2 its the distance formula..hard to type on here
Given the center and a point on the circle, you can use this formula to find the radius of the circle. Write a program that prompts the user to enter the center and a point on the circle. The program should then output the circles radius, diameter, circumference, and area. The program must have at least the following functions:
distance - this function takes as its parameters four numbers that represent two points in the plane and returns the distance between them.
radius - this function takes as its parameters four numbers that represent the center and a point on the circle, calls the function, distance, to find the radius of the circle, and returns the circles radius.
circumference: this function takes as its parameter a number that represents the radius of the circle and returns the circle's circumference (if r is the radius, the circumference is 2*pie*r)
area: this function takes as its parameter a number that represents the radius of the circle and returns the circles area. (if r is the radius, the area is (pie)(r)^2 ...thats pie times r squared.
assume that pie=3.1416
____________________________________________________________________________
I'm just confused on how to set this all up. so i just typed in all the code i have an idea about and maybe one of you guys can help set this thing up for me and give your thoughts on how to do this.. Any information is appreciated!!! Thanks guys.
//I have to prompt to enter a center and a point on the circle so maybe something like this:
cout<<"Enter a center point: ";
cin>>x1, y1;
cout<<"Enter a point on the circle: ";
cin>>x2, y2;
//my functions will be something like this: maybe im not sure
int distance (int x1, int y1, int x2, int y2)
{
int dx = x2 - x1;
int dy = y2 - y1;
float dsquared = dx*dx + dy*dy;
float result = sqrt (dsquared);
cout<<"The distance of the circle is "<<result<<"."<<endl;
}
int radius (int x1, int y1, int x2, int y2)
{
float radius = distance (x1, y1, x2, y2);
float result = area (radius);
cout<<"The radius of the circle is "<<result<<"."<<endl;
}
int circumference(float radius)
{
float circumference = 3.1416 * (radius * 2);
cout<<"The circumference of the circle is " <<circumference<< "."<<endl;
//ok im not sure on this one because he says the function "area" should be made void and
//the return value should come from a reference parameter.
void area(float radius)
{
float area = 3.1416 * radius * radius;
return area;
}