Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #include<iostream>
  2. #include "C:\MinGW\lib\gcc\mingw32\4.8.1\circleType.h"
  3. using namespace std;
  4. class Cylinder: public circleType {
  5.  
  6. public:
  7. void print();
  8.  
  9. void setRadiusBase(double r){
  10.  
  11. if(r>=0){
  12. radius=r;
  13. }else{
  14. radius=0;
  15. }
  16. }
  17. double getRadius(){
  18. return radius;
  19. }
  20. double surfaceArea(){
  21. circleType t=circleType(radius);
  22. double area=t.Area();
  23.  
  24. return area;
  25. }
  26.  
  27. double volume(){
  28. double vol=surfaceArea()*height;
  29. return vol;
  30. }
  31. double setCenter(double x1,double y1){
  32. x=x1;
  33. y=y1;
  34. }
  35.  
  36.  
  37. Cylinder(double r = 0,double h=0){
  38. radius=r;
  39. height=h;
  40. }
  41.  
  42. private:
  43. double radius;
  44. double height;
  45. double x,y;
  46. };
  47.  
  48. int main(){
  49. double r,h;
  50. cout<<"Enter the radius of the base: ";
  51. cin>>r;
  52. cout<<"Enter the height of the cylinder: ";
  53. cin>>h;
  54. Cylinder x;
  55. x=Cylinder(r,h);
  56. double area=x.surfaceArea();
  57. cout<<"Surface area of cylinder: "<<area;<<endl;
  58. double vol=x.volume();
  59. cout<<"Volume of cylinder: "<<vol<<endl;
  60. }
  61.  
  62. #ifndef CIRCLETYPE_H_INCLUDED
  63. #define CIRCLETYPE_H_INCLUDED
  64.  
  65.  
  66. class circleType
  67. {
  68. public:
  69. void print();
  70.  
  71. void setRadius(double r){
  72. if(r>=0){
  73. radius=r;
  74. }else{
  75. radius=0;
  76. }
  77. }
  78. double getRadius(){
  79. return radius;
  80. }
  81. double Area(){
  82. double area=3.14*radius*radius;
  83. return area;
  84. }
  85.  
  86. double circumference(){
  87. double circum=2*3.14*radius;
  88. return circum;
  89. }
  90. circleType(double r = 0){
  91. radius=r;
  92. }
  93.  
  94. private:
  95. double radius;
  96. };
  97.  
  98.  
  99. #endif // CIRCLETYPE_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement