Ok, I'm getting closer. This program should take input from user - x,y points of center of two circles, and the radius. The program determines the relationship of the circles - either Intersection, Separation or Coverage. I have a few errors and think my problems lies with my variable names. Also, one error is "pow" does not take one parameter (haven't used the power much). Please help!!
#include <iostream.h>
#include <math.h>
class circle{
public:
double x1, y1, r1, x2, y2, r2;
void initial();
int distance (int x, int y);
double relation (double r1, double r2);
};
void circle::initial ()
{
cout << "Enter circle 1: " << endl;
cin >> x1 >> y1 >>r1;
cout << "Enter circle 2: " << endl;
cin >> x2 >> y2 >>r2 ;
}
double relation(double r1, double r2)
{
if (fabs(r1-r2) <= (d) <= (r1+r2))
cout << "Intersection" << endl;
else if
( d > (r1 + r2))
cout << "Separation " << endl;
else
cout << "Coverage" << endl;
}
int circle::distance ( int x, int y)
{
double d;
x= pow(x1 - x2);
y= pow(y1 - y2);
d = sqrt (x+y);
}
int main()
{
circle c1, c2;
c1.initial() ;
c2.initial() ;
cout<<"The relations of c1 and c2 is " << relation(c1,c2)<<endl;
return 0;
}



LinkBack URL
About LinkBacks



Still getting errors "d" undeclared identified in relation, and no operator defined which takes right hand operand of type class circle in main function on the cout line. Also, I know my relation should return strings and not cout statements, but not sure how to do that. The main function cannot be changed. Thanks!!