Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <math.h>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. class CIRCLE{
  9. float radius;
  10. string color;
  11. public:
  12. void SetRadius(float dim);
  13. void SetColor(string clr);
  14. float GetRadius();
  15. string GetColor();
  16. CIRCLE();
  17. CIRCLE(float dim, string clr);
  18. CIRCLE (const CIRCLE &s);
  19. ~CIRCLE();
  20. friend float Perimeter(CIRCLE *SP);
  21. float Area();
  22. };
  23.  
  24. void CIRCLE::SetRadius(float dim){
  25. radius=dim;
  26. }
  27.  
  28. void CIRCLE::SetColor(string clr){
  29. color=clr;
  30. }
  31.  
  32. float CIRCLE::GetRadius(){
  33. return radius;
  34. }
  35.  
  36. string CIRCLE::GetColor(){
  37. return color;
  38. }
  39.  
  40. CIRCLE::CIRCLE(){
  41. radius=10;
  42. color="green";
  43.  
  44. }
  45.  
  46. CIRCLE::CIRCLE(float dim, string clr){
  47. radius=dim;
  48. color=clr;
  49.  
  50. }
  51.  
  52. CIRCLE::CIRCLE(const CIRCLE &s){
  53. radius=s.radius;
  54. color=s.color;
  55.  
  56. }
  57.  
  58. CIRCLE::~CIRCLE(){
  59.  
  60. }
  61.  
  62. float Perimeter(CIRCLE *s){
  63. float perimeter;
  64. perimeter=2*M_PI*s->radius;
  65. return perimeter;
  66. }
  67.  
  68. float CIRCLE::Area(){
  69. float area;
  70. area=M_PI*pow(radius,2);
  71. return area;
  72. }
  73.  
  74. void Generic1(CIRCLE s){
  75.  
  76. }
  77.  
  78. CIRCLE Generic2(CIRCLE &s){
  79.  
  80. return s;
  81. }
  82.  
  83. class CONE:public CIRCLE{
  84. float height;
  85. public:
  86. void SetHeight(float dim){
  87. height=dim;
  88. }
  89.  
  90. float GetHeight(){
  91. return height;
  92. }
  93.  
  94. float Volume(){
  95. float volume;
  96. volume=(Area()*height)/3;
  97. return volume;
  98. }
  99. CONE(float dim){
  100. height=dim;
  101. }
  102. };
  103.  
  104. int main(int argc, char** argv){
  105. float r;
  106. string c;
  107. cin>>r;
  108. cin>>c;
  109. CIRCLE c1(r, c);
  110. cin>>r;
  111. CONE c2(r);
  112. cout<<setprecision(2)<<fixed<<Perimeter(&c1)<<endl;
  113. cout<<setprecision(2)<<fixed<<c1.Area()<<endl;
  114. cout<<setprecision(2)<<fixed<<c2.Volume();
  115.  
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement