#include <iostream> #include <cmath> using namespace std; #define PI 3.1415926 class Point {public:void setpoint (float i,float j); Float GetX () {return x;} Float GetY () {return y;} Float Dr (Point &p1,point &p2); Private:float x; Float y; }; void Point::setpoint (float i,float j) {x=i; Y=j; } float point::d R (Point &p1,point &p2) {float dr=0,dx=0,dy=0; dx=p1.x-p2.x; DY=P1.Y-P2.Y; DR=SQRT (Dx*dx+dy*dy); Return Dr; } class Circle:public Point {public:circle (float x1,float y1,float x2,float y2) {midpoint.setpoint (x1,y1); AROUNDP Oint.setpoint (x2,y2);} float SETR (); void Circle_area (); Float Getr () {return r;} Float Getarea () {return area;} float lcircle (); Private:float area; float R; Point midpoint; Point Aroundpoint; }; Float Circle::setr () {r=dr (midpoint,aroundpoint); return R; } void Circle::circle_area () {r=Setr (); Area=pi*r*r; cout<< "The area of the bottom circle is:" <<area<<endl; } float Circle::lcircle () {r=setr (); float L; L=2*pi*r; return l; } class Cylinder:public Circle {public:cylinder (float x1,float y1,float x2,float y2,float H1): Circle (X1,Y1,X2, y2), H (H1) {} void Cylinderarea (); void Cylinder_volume (); Private:float h; }; void Cylinder::cylinderarea () {float S; S=2*getarea () +lcircle () *h; cout<< "The surface area of the cylinder is:" <<s<<endl; } void Cylinder::cylinder_volume () {float V; V=getarea () *h; cout<< "Cylinder Volume:" <<v<<endl; } int main () {Cylinder cy1 (0,0,3,4,1.0); Cy1.circle_area (); Cy1.cylinderarea (); Cy1.cylinder_volume (); return 0; }
Run results
Tenth to tenth Week Project 1-point-circle-cylinder Group Design (3)