So I have to write a program to output whether a point is inside or outside a circle, but I can only get the program to ask me for one set of coordinates.
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
bool promptYesNo (string question);
int main ()
{
double x, y, r, d, px, py, dx, dy, da;
char Yes, No;
string promptYesNo;
cout << "Please enter the x and y coordinates of the center of the circle" << endl;
cin >> x >> y;
cout << "Please enter the radius of the circle" << endl;
cin >> r;
{cout << "Please enter the x and y coordinates of a point" << endl;
cin >> px >> py;
dx = pow (px-x, 2);
dy = pow (py-y,2);
da = dx + dy;
d = sqrt (da);
if (d <= r)
cout << "Inside" << endl;
else if (d > r)
cout << "Outside" << endl;
}
cout << "Enter another point? <Yes or No>" << endl;
if(cin>> Yes)
{
cout << "Please enter the x and y coordinates of a point" << endl;
cin >> px >> py;
dx = pow (px-x, 2);
dy = pow (py-y,2);
da = dx + dy;
d = sqrt (da);
if (d <= r)
cout << "Inside" << endl;
else if (d > r)
cout << "Outside" << endl;
}
return 0;
}
Any help would be appreciated. Thanks.