Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. class box {
  4.  
  5. private:
  6. double length;
  7. double breadth;
  8. double height;
  9. public:
  10. void setlength(double);
  11. void setbreadth(double);
  12. void setheight(double);
  13. double getlength() const;
  14. double getbreadth() const;
  15. double getheight() const;
  16. };
  17. void box::setlength(double len)
  18. {
  19. length = len;
  20. };
  21.  
  22. void box::setbreadth(double B)
  23. {
  24. breadth = B;
  25. };
  26.  
  27. void box::setheight(double H)
  28. {
  29. height = H;
  30. };
  31.  
  32. double box::getlength() const
  33. {
  34. return length;
  35. };
  36.  
  37. double box::getheight() const
  38. {
  39. return height;
  40. };
  41.  
  42. double box::getbreadth() const
  43. {
  44. return breadth;
  45. };
  46.  
  47. int main()
  48. {
  49. box box1;
  50. box box2;
  51. double volume = 0.0;
  52.  
  53. box1.setheight(5.0);
  54. box1.setlength(6.0);
  55. box1.setbreadth(7.0);
  56.  
  57. box2.setheight (10.0);
  58. box2.setlength (12.0);
  59. box2.setbreadth (13.0);
  60.  
  61. volume = box1.getheight() * box1.getlength() * box1.getbreadth();
  62. cout << "Volume of Box1 : " << volume <<endl;
  63. volume = box2.getheight()* box2.getlength() * box2.getbreadth();
  64. cout << "Volume of Box2 : " << volume <<endl;
  65. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement