Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USE ((PYTHON)) ONLY (Geometry: two circles) Write a program that prompts the use

ID: 644642 • Letter: U

Question

USE ((PYTHON)) ONLY

(Geometry: two circles) Write a program that prompts the user to enter the center coordinates and radii of two circles and determines whether the second circle is inside the first or overlaps with the first, as shown in Figure 4.11. (Hint: circle2 is inside circle) if the distance between the two centers

Explanation / Answer

import java.util.Scanner; public class TwoCircles { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.print("Enter Circle 1 center x-, y-coordinates, and radius: "); double X1 = input.nextDouble(); double Y1 = input.nextDouble(); double radius1 = input.nextDouble(); System.out.print("Enter Circle 2 center x-, y-coordinates, and radius: "); double X2 = input.nextDouble(); double Y2 = input.nextDouble(); double radius2 = input.nextDouble(); double distance = Math.pow((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2), 0.5); if (radius2 >= radius1){ if (distance = radius2){ if (distance (radius1 + radius2)){ System.out.println("Circle 2 does not overlap Circle 1.");} else { System.out.println("Circle 2 overlaps Circle 1.");} } }