1. Prompt and read in the x and y coordinates of the center of circle A: 2. Prom
ID: 3888423 • Letter: 1
Question
1. Prompt and read in the x and y coordinates of the center of circle A: 2. Prompt and read in the radius of circle A 3. Prompt and read in the x and y coordinates of the center of circle B: 4. Prompt and read in the radius of circle B: 5. Prompt and read in the x and y coordinates of the center of circle C: 6. Prompt and read in the radius of circle C: 7. Prompt and read in the x and y coordinates of the query point; 8. Point (x. y) is contained in the circle with center (cr. cy) and radius r if: (x - ca) + (y-cy) s r. By applying this equation to each circle and the query point, determine which circles contain the query point. Note: The operator is NOT the square operator in C++. To square a value simply mnltiply it by itself. 9. Output should be one of the following: Circles A, B, and C contain point (x,y) Circles A and B contain point (x,y). Circles A and C contain point (x,y. Circles B and C contain point (,y) Circle A contains point (x,y) Circle B contains point (x,y) Circle C contains point (x,y). No circle contains point (x,y). In the output z and y should be replaced by the float ing point numbers which are the actual coordinates of and y.Explanation / Answer
Hi,
/******************************************************************************
"Created By" - Abc xyz , 21 Sept, 2017, "Syponsis"
*******************************************************************************/
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
float xA; // x coordinates of A
float yA; // y coordinates of A
float xB; // x coordinates of B
float yB; // y coordinates of B
float xC; // x coordinates of C
float yC; // y coordinates of C
float xP; // x coordinates of Point
float yP; // y coordinates of Point
float pA; // Point of A
float pB; // Point of B
float pC; // Point of C
float rA, rB, rC; // radius of A, B, C
cout<<"Enter x and y coordinates of center of circle A:"<<endl;
cin>>yA; // read x of A
cin>>yA; // read y of A
cout<<"Enter the redius of the circle A:"<<endl;
cin>>rA; // read radius of A
cout<<"Enter x and y coordinates of center of circle B:"<<endl;
cin>>yB; // read x of B
cin>>yB; // read y of B
cout<<"Enter the redius of the circle B:"<<endl;
cin>>rB;; // read radius of B
cout<<"Enter x and y coordinates of center of circle C:"<<endl;
cin>>yC; // read x of C
cin>>yC; // read y of C
cout<<"Enter the redius of the circle C:"<<endl;
cin>>rC;; // read radius of C
cout<<"Enter x and y coordinates of the query point:"<<endl;
cin>>xP; // read x of Point
cin>>yP; // read y of Point
// find Circle A
pA = (sqrt((xP-xA)*(xP-xA)+(yP-yA)*(yP-yA)));
// find Circle B
pB = (sqrt((xP-xB)*(xP-xB)+(yP-yB)*(yP-yB)));
// find Circle C
pC = (sqrt((xP-xC)*(xP-xC)+(yP-yC)*(yP-yB)));
if (pA <= rA && pB <= rB && pC <= rC) {
cout<<"Circles A, B, and C contains point(" << xP <<"," << yP <<")"<<endl;
} else if (pA <= rA && pB <= rB) {
cout<<"Circles A and B contains point(" << xP <<"," << yP <<")"<<endl;
} else if (pA <= rA && pC <= rC) {
cout<<"Circles A and C contains point(" << xP <<"," << yP <<")"<<endl;
} else if (pB <= rB && pC <= rC) {
cout<<"Circles B and C contains point(" << xP <<"," << yP <<")"<<endl;
} else if (pA <= rA) {
cout<<"Circle A contains point(" << xP <<"," << yP <<")"<<endl;
} else if (pB <= rB) {
cout<<"Circle B contains point(" << xP <<"," << yP <<")"<<endl;
} else if (pC <= rC) {
cout<<"Circle C contains point(" << xP <<"," << yP <<")"<<endl;
} else {
cout<<"No circles contains point(" << xP <<"," << yP <<")"<<endl;
}
return 0;
}
Let me know if any change required.
Thank you
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.