11th Week "Project 1-point-circle-cylinder Group Design 3"

Source: Internet
Author: User

/* *copyright (c) 2016, *all Rights reserved, School of computer and Control engineering, Yantai University. * File name: Main.cpp * Author: Chang Heng * Completion Date: May 3, 2016 * version number: v1.0 * * Problem Description: Then the Circle class is the direct base class, derive a cylinder (cylinder) class, and then increase the data member H (high), As well as the member functions of the cylindrical surface area and the member function volume to calculate the cylinder volume, implement the required member functions, and design the main function to complete the test. * Input Description: No * Output description: Output as required */#include <iostream> #include <cmath> #define PI 3.14using namespace Std;class point{    Public:point (double m,double n);    void Pointshow ();p rivate:double x; Double y;};    Point::P oint (double m,double n) {x=m; Y=n;}    void point::p ointshow () {cout<<) the center coordinates are: "<<endl; cout<<x<< "" <<y<<endl;}    Class Circle:public point{public:circle (double m,double n,int R2);    void area ();    void Circleshow (); int Getr ();p rivate:int R;}; Circle::circle (double m,double n,int R2):P oint (m,n) {r=r2;}    void Circle::area () {double S;    S=pi*r*r; cout<< "The area of the circle is:" &LT;&LT;S&LT;&LT;ENDL;} void Circle::circleshow () {pointshow ();} int Circle::getr () {return r;} Class Cylinder:public Circle{public:cylinder (double x1,double y1,int r1,int H1);    void Biaoarea (); void volume ();p rivate:int h;}; Cylinder::cylinder (double x1,double y1,int r1,int H1): Circle (X1,Y1,R1) {h=h1;}    void Cylinder::biaoarea () {int R1;    Double s1,s2,s3;    R1=getr ();    S1=PI*R1*R1;    S2=2*pi*r1*h;    S3=S1+S2; cout<< "The surface area of the cylinder is:" &LT;&LT;S3&LT;&LT;ENDL;}    void Cylinder::volume () {int R1;    Double s1,v;    R1=getr ();    S1=PI*R1*R1;    V=s1*h; cout<< "The volume of the cylinder is:" &LT;&LT;V&LT;&LT;ENDL;}    int main () {double x1,y1;    int r1,h1;    cout<< "Please enter center coordinates:" <<endl;    cin>>x1>>y1;    cout<< "Please enter the radius of the circle:" <<endl;    cin>>r1;    cout<< "Please enter the height of the cylinder:" <<endl;    cin>>h1;    Circle c (X1,Y1,R1);    C.circleshow ();    C.area ();    Cylinder d (X1,Y1,R1,H1);    D.biaoarea (); D.volume ();}

11th 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.