The following formula gives the distance between 2 points x1,x2 and y1,y2 in the cartesian plane:
sqrt(pow(x1-x2,2) - pow(y1-y2,2))
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 user to enter the center a point on the circle. The program should then output the circle radius, diameter, circumference and area. your program must have at least the following function:
a)distance:this function takes as its parameters four numbers that represent tow points in the plane and returns the distance between them.
b)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 return the circle radius.
c)circumference: this function takes as its parameter a number that represents the radius of the circle and returns the circle circumference.
d)area: this function takes as its parameter a number that represents the radius of the circle and return the circle area
a) distance, here they want you to just implement the formula: d(x,y) = |x - y| means:
distance(x1,x2,y1,y2) = sqrt((x1-y1)^2 + (x2-y2)^2)
b) radius, you have to think about the meaning of distance. after a while of thinking you should come to the conclusion: hey! in this case distance of the 2 points equals the radius! But really, think about it, because it is a serious mathematical issue.
c) circumference: read wikipedia! circ = 2 * Pi * radius
If (x1,y1) is the center point of the circle and (x2,y2) is a point on the circle, then the radius
of the circle is exactly the distance between those two points.
ya i know.. i did think about it that distance = radius.. then if it true i think i dont need to write the radius function but the question did ask me to write a radius function.. or the radius function is to call the distance function to return back as radius function but not distance function??