Design (in pseudocode ) and implement a program to determine if a circle is eith
ID: 3748293 • Letter: D
Question
Design (in pseudocode) and implement a program to determine if a circle is either completely inside, overlapping with, or completely outside another circler. The program asks the user to enter the center point (X1, Y1) and the radius (R1) for the first circle C1, and the center point (X2, Y2) and the radius (R2) for the second circle C2. The program then determines if the second circle C2 is either completely inside, or overlapping with, or completely outside the first circle C1. Hint: use the sum of R1 and R2 and the distance between the centers to solve the problem. Document your code, properly label the input prompts, and organize the outputs as shown in the following sample runs.
Example:
Circle 1 center is: (0,0)
Circle 1 radius is: 6
Circle 2 center is: (1,1)
Circle 2 radius is: 1
Judgment: Circle 2 is completely inside circle 1
Explanation / Answer
print prompt
"Enter the circle 1 center"
C1=input(x1,y1)
print prompt
"Enter the circle 1 radius"
R1=input(radius)
print prompt
"Enter the circle 2 center"
C2=input(x2,y2)
print prompt
"Enter the circle 2 Radius"
R2=input(radius)
caluclate d =distance between centers
//d=sqrt((x1-x2)*(x1-x2) +(y1-y2)*(y1-y2))
caluclate p=R1+R2
caluclate q=R1-R2
if q <0 //making sure that distance is +ve
q=-q
if "d>p"
print circle is completely outside the another circle
else
{
if "d>q"
print circles are intersecting
else
{
if R1>R2 //this is for which circle is inside the other
print circle 2 lies completely inside circle 1
else
print circle 1 lies completely inside circle 2
}
}