Tenth to tenth Week Project 1-point-circle-cylinder Group Design (3)

Source: Internet
Author: User

#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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.