disjolat I iF statement-Coosle 13) conplete the following code to test whether t
ID: 3585808 • Letter: D
Question
disjolat I iF statement-Coosle 13) conplete the following code to test whether two cireles, each having a user defined redius and a fixed center potnt lying along the sane hortzontal line, are disjoint, over lapping, or nutualty contatned. Let's say that when circtes touch at a stngte point, we consider then to be overlapping or nutually contalred, as ts approprtate. Look at the switch statenent to declde Sow to set the result vartable. Lnport java.util.scanser ; pubLte class Circteöverlap publte static vold natn(stringt args) ror (tat center2-26; center.Explanation / Answer
copy and paste the below code below the comment section of your program. Run it and comment for any changes.
**Code:
double distance = Math.pow((xcenter1 - xcenter2) * (xcenter1 - xcenter2) + (ycenter1 - ycenter2) * (ycenter1 - ycenter2), 0.5);
if (r2 >= r1 && distance <= (r2 - r)){
result = 1;
}
else if (r1 >= r2 && distance <= (r1 - r2) ) {
result = 3;
}
else if (distance > (r1 + r2)){
result = 1;
}
else {
result = 2;}
}
**Comment for any further queries.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.