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

#include <iostream> #include <cmath> #include <iomanip> using namespace std; cla

ID: 3845469 • Letter: #

Question

#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

class Circle
{
public:
int r;
int cenx;
int ceny;

public:
void SetRadius(double);
void Centerset(double, double);
double area() const;
double X() const;
double y() const;
double getradius() const;

};
void Circle::SetRadius(double Rcircle)
{
r = Rcircle;
cout << "the radius: " << r << endl;

}
void Circle::Centerset(double aforX, double bforY)
{

cenx = aforX;
ceny = bforY;

}
double Circle::area() const
{

return 3.14 * r * r;


}
double Circle::X() const
{
return cenx;
}
double Circle::y() const
{
return ceny;
}
double Circle::getradius()
{
return r;
}
};
class Intersect
{
double m;
double c;
public:
Line(int m1,int c1)
{
m=m1;
c=c1;
}
  
double getM()
{
return m;
}
double getC()
{
return c;
}
void display()
{
cout<<" line y= "<<m<<" * x + " <<c;
}
double setcircle(double,double,double);
double setline(double,double);
void getintersectpoints();


};

int main()
{
Circle temp;
Intersection lin;
double A,B,C;
double m=lin.getM(),c=lin.getC(),a=temp.Centerset().X(),b=temp.Centerset().y();
double x1,y1,x2,y2, d;

cout << "Enter the radius: " << endl;
cin >> temp.r;
temp.SetRadius(temp.r);
cout << "Enter Center x: " << endl;
cin >> temp.cenx;
cout << "Enter Center y: " << endl;
cin >> temp.ceny;

temp.Centerset(temp.cenx,temp.ceny);


  
A=pow(m,2)+1; // A=m^2 + 1
B=2*(m*c-m*b-a); //B=2(mc-mb-a)
C= pow(a,2)+pow(b,2)-pow(r,2)+pow(c,2)-2*b*c;//a^2+b^2-r^2+c^2-2bc
  
d=sqrt(pow(B,2)-4*A*C); //calculate sqrt(B^2-4AC)
  
//first root x=(-B+sqrt(B^2-4AC)) / 2A
x1=(-B+d)/(2*A);
  
//second root x=(-B-sqrt(B^2-4AC)) / 2A
x2=(-B+d)/(2*A);
  
//using line equation to get y values
y1=m*x1+c;
y2=m*x2+c;
  
// *intersection=new Point[2];
// intersection[0] =Point(x1,y1);
// intersection[1] =Point(x2,y2);
cout << "Radius: " << temp.getradius() << endl;
cout << "Center X " << temp.X() << " Center Y: " << temp.y() << endl;
cout << "The Area: " << temp.area() << endl;

return 0;
}

####getting error stray 240 thanks

Explanation / Answer

#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

class Circle
{
public:
    int r;
    int cenx;
    int ceny;
    void SetRadius(double);
    void Centerset(double, double);
    double area() const;
    double X() const;
    double y() const;
    double getradius() const;
};

void Circle::SetRadius(double Rcircle)
{
    r = Rcircle;
    cout << "the radius: " << r << endl;

}
void Circle::Centerset(double aforX, double bforY)
{

    cenx = aforX;
    ceny = bforY;

}
double Circle::area() const
{

   return 3.14 * r * r;


}
double Circle::X() const
{
    return cenx;
}
double Circle::y() const
{
    return ceny;
}
double Circle::getradius() const
{
    return r;
}

class Intersect
{
    double m;
   double c;
   public:
       void intersection(int m1,int c1)
       {
           m=m1;
           c=c1;
       }
       double getM()
       {
           return m;
       }
       double getC()
       {
           return c;
       }
       void display()
       {
           cout<<" line y= "<<m<<" * x + " <<c;
       }
double setcircle(double,double,double);
double setline(double,double);
void getintersectpoints();

};

int main()
{
    Circle temp;
    Intersect lin;
    double A,B,C;
    double m=lin.getM(),c=lin.getC(),a=temp.X(),b=temp.y();
    double x1,y1,x2,y2, d;

    cout << "Enter the radius: " << endl;
    cin >> temp.r;
    temp.SetRadius(temp.r);
    cout << "Enter Center x: " << endl;
    cin >> temp.cenx;
    cout << "Enter Center y: " << endl;
    cin >> temp.ceny;

    temp.Centerset(temp.cenx,temp.ceny);


        
    A=pow(m,2)+1; // A=m^2 + 1
    B=2*(m*c-m*b-a); //B=2(mc-mb-a)
    C= pow(a,2)+pow(b,2)-pow(temp.r,2)+pow(c,2)-2*b*c;//a^2+b^2-r^2+c^2-2bc
    
    d=sqrt(pow(B,2)-4*A*C); //calculate sqrt(B^2-4AC)
    
       //first root x=(-B+sqrt(B^2-4AC)) / 2A
    x1=(-B+d)/(2*A);
    
       //second root x=(-B-sqrt(B^2-4AC)) / 2A
    x2=(-B+d)/(2*A);
    
       //using line equation to get y values
    y1=m*x1+c;
    y2=m*x2+c;
    
//   *intersection=new Point[2];
   // intersection[0] =Point(x1,y1);
   // intersection[1] =Point(x2,y2);
    cout << "Radius: " << temp.getradius() << endl;
    cout << "Center X " << temp.X() << " Center Y: " << temp.y() << endl;
    cout << "The Area: " << temp.area() << endl;

    return 0;
}