Thread: need help with program...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    74

    ...jump to last reply

    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;
    }
    Last edited by LouB; 06-24-2002 at 09:12 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM