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

I don\'t even know where to start SAMPLE INPUT: 2.5 1.3 4.1 (X and Y values, fol

ID: 3528413 • Letter: I

Question

I don't even know where to start

SAMPLE INPUT: 2.5 1.3 4.1 (X and Y values, followed by the radius) -3.8 6.1 5.0 SAMPLE OUTPUT: INPUT: Use the data above (The program should work for any data set.) (A driver program will be provided to test the "is_circle" function) OUTPUT: As above TO HAND IN: The code with documentation The output A file with the source code (three files) and output files To use inheritance. Use the point class as given (see page 3 of this handout). Derive a Circle class "circletype" from the point class. Circletype will have a private floating point member radius, a constructor, an area function, a circumference function, an observer for the radius, and a transformer set_radius. Also, add a boolean function "is_in_circle." This will take a point on the XY plane and test to see if it is within the circle. The main program should read the point (its X and Y coordinates), which is the center of the circle, and then the radius using an end-of-file loop. Il should write the output to a file in neat columns, including the center, the radius, the area and circumference of each circle. Use column headings. Use a separate driver program to test the is_in_circle function. Read the center and radius of the circle. Then for each point given, indicate whether il is in the circle. You can use cin and cout to test the is_in_circle function. Use a constructor with default arguments for the circle, setting the radius to 1 by default. No credit will be given unless all data members are private Also, no credit will be given unless inheritance is used. It's OK to put the specification and implementation in the same file for each class. Further specifications will be given for the circletype class, as well as the data for the is_circle function. The program will have three files. The main, point.cpp, and circle.cpp. There will also be an input and output file.

Explanation / Answer

#include<iostream>
using namespace std;

class point
{
public:
point(double initial_x=0.0,double initial_y = 0.0)
{
x = initial_x;
y = initial_y;
}
void reset_point(double new_x =0, double new_y = 0)
{
x =new_x;
y = new_y;
}
double get_x() const
{
return x;
}
double get_y() const
{
return y;
}
private:
double x;
double y;

};

class circletype:public point
{
private:
double radius;
public:
circletype()
{
radius = 1;
}
circletype(double x, double y, double rad=0):point(x,y), radius(rad)
{
}
double get_area()
{
return 3.14*radius*radius;
}
double get_circumference()
{
return 3.14*2*radius;
}
double get_radius()
{
return radius;
}
void set_radius(double rad=0)
{
radius = rad;
}
bool is_in_circle(int xx, int yy)
{
return ( (get_x()-xx)*(get_x()-xx) + (get_y()-yy)*(get_y()-yy) <= radius*radius);
}


};


int main()
{
double x,y,rad;
double x1,y1,rad1;
cout <<" enter cetre of circle ";
cin >> x >>y;

cout << endl;
cout <<" enter radius of circle ";
cin >> rad;
cout << endl;
cout << "enter centre of circle 2";
cin>> x1 >> y1;
cout << endl;
cout <<" enter radius of circle ";
cin >> rad1;
cout << endl;

circletype circle1(x,y,rad);
circletype circle2(x1,y1,rad1);
cout << "CENTRE RADIUS AREA CIRCUMFERENCE" << endl;
cout << circle1.get_x() << " " << circle1.get_y() << " " <<circle1.get_radius() << " " << circle1.get_area() << " " << circle1.get_circumference() << endl;
cout << circle2.get_x() << " " << circle2.get_y() << " " <<circle2.get_radius() << " " << circle2.get_area() << " " << circle2.get_circumference() << endl;

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote