tepong

08-21-2010, 08:11 PM

Write a program that prompts the user to enter the center coordinates and radius of two circles and determines whether the second circle is inside the first or overlaps with the first.

Hint: circle2 is inside circle1 if the distances between the two centers

<=|r1 – r2|

circle2 overlaps circle1 if the distance between the two centers

<=|r1 + r2|

So i have found the correct formula but dont know how to write the coding. Can someone help me....

circle2 is inside circle1 if:

distance(x1,y1,x2,y2) <= Math.abs(r1-r2)

circle2 overlaps circle1 if:

distance(x1,y1,x2,y2) <= Math.abs(r1+r2

Hint: circle2 is inside circle1 if the distances between the two centers

<=|r1 – r2|

circle2 overlaps circle1 if the distance between the two centers

<=|r1 + r2|

So i have found the correct formula but dont know how to write the coding. Can someone help me....

circle2 is inside circle1 if:

distance(x1,y1,x2,y2) <= Math.abs(r1-r2)

circle2 overlaps circle1 if:

distance(x1,y1,x2,y2) <= Math.abs(r1+r2