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

Write the function compareCircles that will accept that following parameters: 1)

ID: 3833157 • Letter: W

Question

Write the function compareCircles that will accept that following parameters: 1) double cX1 2) double cY1 3) double cX2 4) double cY2 5) double r1 6) double r2 The point C1 = (cX1, cY1) is the center of Circle #1. The point C2 = (cX2, cY2) is the center of Circle #2. The value r1 is the radius of Circle #1 and the value r2 is the radius of Circle #2. The function will return the following values: 1) The function will return 1, if the centers of the two circles C1 and C2 are the same points and the two radii r1 and r2 are equal. 2) The function will return 2, if the radii r1 and r2 are equal, the distance between the two centers C1 and C2 is equal to 2*r1. 3) The function will return 3, if the centers of the two circles C1 and C2 are the same point but the two radii r1 and r2 are not equal 4) Otherwise the function will return 4 The distance between the two points (cX1, cY1) and (cX2, cY2) can be found using the distance formula: Squareroot (cX2 - cX1)^2 + (cY2 - cY1)%2 Use the following main() function. All you need is to implement the function compareCircles(). int main() {double cX1, cY1, cX2, cY2, r1, r2; int ret; coutcX1>>cY1; coutr1; coutcY2; coutr2; cout

Explanation / Answer

CircleComp.CPP :
________________

#include<iostream>
#include<math.h>
using namespace std;
int compareCircles(double,double,double,double,double,double);
int main()
{
   double cX1,cX2,cY1,cY2,r1,r2;
   int ret;
  
   cout<<"Enter the center of Circle #1: ";
   cin>>cX1>>cY1;
   cout<<"Enter the radius of Circle #1: ";
   cin>>r1;
  
   cout<<endl;
  
   cout<<"Enter the center of Circle #2: ";
   cin>>cX2>>cY2;
   cout<<"Enter the radius of Circle #2: ";
   cin>>r2;
  
   cout<<endl;
  
   ret = compareCircles(cX1,cY1,cX2,cY2,r1,r2);
  
   cout<<"The return value is: "<<ret<<endl;
}
int compareCircles(double cX1,double cY1,double cX2,double cY2,double r1,double r2)
{
   int C1 = (cX1,cY1);
   int C2 = (cX2,cY2);
  
   int distance = sqrt( (cX2-cX1)*(cX2-cX1) + (cY2-cY1)*(cY2-cY1) );
  
   if(C1 == C2 && r1 == r2)
       return 1;
   else if(r1 == r2 && distance == 2*r1)
       return 2;
   else if(C1 == C2 && r1 != r2)
       return 3;
   else
       return 4;
}

Sample Input and Output:

_____________________

Run 1 :
______

Enter the center of Circle #1: 0 0
Enter the radius of Circle #1: 5

Enter the center of Circle #2: 0 0
Enter the radius of Circle #2: 5

The return value is: 1

Run 2 :
______

Enter the center of Circle #1: 0 0
Enter the radius of Circle #1: 8

Enter the center of Circle #2: 0 0
Enter the radius of Circle #2: 9

The return value is: 3

Run 3:
_____

Enter the center of Circle #1: 2 3
Enter the radius of Circle #1: 7

Enter the center of Circle #2: 5 1
Enter the radius of Circle #2: 4

The return value is: 4