• 08-21-2010, 09:04 PM
tepong
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
• 08-21-2010, 09:41 PM
Fubarable
Quote:

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

The secret to success here is to break your problem down into small steps, and then attack each step one at a time. A great resource that can help you get started is this link: So, You Need to Write a Program but Don't Know How to Start

Since we don't know where your stuck, it's difficult to help you. Just stating that you don't know how to write the code again leaves us with the option of referring you to the tutorials, and that's about it. You know of course that no one here is going to write this for you. Please have a look at the link above, and then try to do as much as you can to solve your problem. You probably can do more than you think you can. Then if you get stuck you can post your attempt, and we'll know how to help you.

Best of luck!