P2: Two Circles

Write a program that prompts the user to enter the center coordinates and radii of two circles and determines their relative positions: whether one circle is inside the other one, two circles overlap each other, or two circles don't overlap each other at all, as shown in the figure below. Note that you need to distinguish "inside" from "overlap" even though "inside" is considered as a case of "overlap." (Hint: circle2 is inside circle1 if the distance between the two centers <= |r1 - r2| and circle1 overlaps circle2 if the distance between the two centers <= |r1 + r2|. Use Math.sqrt() to calculate the square root of a number, Math.abs() for absolute value and Math.PI). Test your program to cover all possible cases.

//Sample skeleton code. You need to add more code to complete the assignment. 
public class TestCircles
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		System.out.println("Enter circle1's center x-, y-coordinates, and radius:"); 
		
		double x = input.nextDouble();
		double y = input.nextDouble();
		double radius = input.nextDouble();
		Circle circle1 = new Circle(x, y, radius);				
		
		System.out.println("Enter circle2's center x-, y-coordinates, and radius:"); 
		Circle circle2 = new Circle(x, y, radius);	
		
		//Sample method call for checking one circle is inside another
		if(circle2.isInside(circle1))
			System.out.println("circle2 is inside circle1.");
			
		//More cases here		
	}
}

class Circle
{
	private double radius;
	private double x;
	private double y;
	
	public Circle(double x, double y, double r)
	{	
	}
	
	public boolean isInside(Circle c)
	{
	}

	public boolean overlap(Circle c)
	{
	}

	public double getArea()
	{
	}
}

//Sample output 
Enter circle1's center x-, y-coordinates, and radius: 0.5 5.1 13 
Enter circle2's center x-, y-coordinates, and radius: 1 1.7 4.5 
circle2 is inside circle1.
The area of circle2 is 11.98% of that of circle1.

Enter circle1's center x-, y-coordinates, and radius: 3.4 5.7 5.5 
Enter circle2's center x-, y-coordinates, and radius: 6.7 3.5 3 
Two circles overlap.
The area of circle2 is 29.75% of that of circle1.

Enter circle1's center x-, y-coordinates, and radius: 3.4 5.5 1 
Enter circle2's center x-, y-coordinates, and radius: 5.5 7.2 1 
Two circles do not overlap.
The area of circle2 is 100.00% of that of circle1.

The file should be named in this format: P2_YourName.txt, for example, P2_JohnDoe.txt. Then submit to the Blackboard (Bb) as attachment by the deadline. The submission link on the Bb will be closed automatically after the deadline. Assignments that fail to follow the instructions will NOT be graded.