/* Maryam Shaheen #1140427 */ import java.util.Scanner; public class Task_2 { // the second Task (geometry : two circles) private static Scanner input; public static void main(String[] args) { input = new Scanner(System.in); System.out.print("Enter Circle 1 center x-, y-coordinates, and radius: ");//printing statement double X1 = input.nextDouble(); // Scanning the x point on the coordinate for the first circle double Y1 = input.nextDouble();// Scanning the y point on the coordinate for the first circle double radius1 = input.nextDouble(); // Scanning the radius for the first circle System.out.print("Enter Circle 2 center x-, y-coordinates, and radius: ");//printing statement double X2 = input.nextDouble(); //Scanning the x point on the coordinate for the second circle double Y2 = input.nextDouble(); //Scanning the y point on the coordinate for the second circle double radius2 = input.nextDouble(); // Scanning the radius for the second circle // calculating the distance between the two circles double distance = Math.pow((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2), 0.5); if (radius2 >= radius1) { // if radius2 is equal or greater than radius1 if (distance <= (radius2 - radius1)) { /* if radius1 subtracted from radius2 is equal or greater than the distance between them then print that circle1 is inside the circle2 */ System.out.println("Circle 1 is inside Circle 2.");//printing statement } } else if (radius1 >= radius2) { // if radius1 is equal or greater than radius2 if (distance <= (radius1 - radius2)) { /* if radius2 subtracted from radius1 is equal or greater than the distance between them then print that circle2 is inside the circle1 */ System.out.println("Circle 2 is inside Circle 1.");//printing statement } } else if (distance > (radius1 + radius2)) { /* if the the addition of radius1 and radius2 is less than the distance between them then print that circle2 does not overlap circle1 */ System.out.println("Circle 2 does not overlap Circle 1.");//printing statement } else { /* if the the addition of radius1 and radius2 is greater than the distance between them then print that circle2 overlaps circle1 */ System.out.println("Circle 2 overlaps Circle 1.");//printing statement } } }