Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. class Rectangle
  9. {
  10. public:
  11. void setData();
  12. void getData();
  13. double diag();
  14. private:
  15. int a, b;
  16. int square;
  17. };
  18.  
  19. double Rectangle::diag()
  20. {
  21. return sqrt(a*a + b*b);
  22. }
  23.  
  24. void Rectangle::setData()
  25. {
  26. cout << "Select the options of your rectangle " << endl;
  27. cin >> a >> b;
  28. }
  29. void Rectangle::getData()
  30. {
  31. cout << "Square of your rectangle is " << a*b << endl;
  32. cout << "Diagonal of your rectangle is " << sqrt(a*a + b*b) << endl;
  33.  
  34. }
  35.  
  36.  
  37.  
  38. int main()
  39. {
  40. Rectangle ABCD;
  41. ABCD.setData();
  42. ABCD.getData();
  43. cout << "Diagonal= " << ABCD.diag() << endl;
  44. system("pause");
  45. }
  46. /*int main()
  47. {
  48. Rectangle ABCD;
  49. Rectangle* MNLK;
  50. ABCD.setData();
  51. ABCD.getData();
  52. MNLK = new Rectangle;
  53. MNLK -> setData();
  54. MNLK->getData();
  55. cin.get();
  56. cin.get();
  57. return 0;
  58. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement