/* *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:" <<S<<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:" <<S3<<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:" <<V<<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"