about | help | code help+videos | done | prefs |
Two circles are said to overlap if the distance between their centers is less than or equal to the sum of their radii. Given the function that calculates the distance between two points (x1, y1) and (x2, y2), define a function that when passed the centers and radii of two circles, returns true if they overlap, false otherwise. double distance(int x1, int y1, int x2, int y2) { double dx = x1 - x2; double dy = y1 - y2; double D = dx*dx + dy*dy; return Math.sqrt(D); } overlap(10, 20, 10, 30, 20, 10) → true overlap(10, 20, 10, 30, 20, 9) → false overlap(50, 50, 10, 40, 40, 10) → true ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 1 Post-solution available
Copyright Nick Parlante 2017 - privacy