Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1.  
  2.  
  3. #include "pch.h"
  4. #include <iostream>
  5.  
  6. using namespace std;
  7. struct circle
  8. {
  9. float radius;
  10. };
  11. struct rectangle
  12. {
  13. float length, width;
  14. };
  15. struct square
  16. {
  17. float length;
  18. };
  19. #include <iomanip>
  20.  
  21. double areacircle(float radius);
  22. double arearectangle(float length,float width );
  23. double areasquare(float slength);
  24. void perirec(float &length, float &width);
  25. double cost1(float &peri, float uni);
  26. int main()
  27. {
  28. float length=0, width=0;
  29. struct circle c;
  30. struct rectangle r1, r2;
  31. struct square s1;
  32. float uni, cost;
  33.  
  34. c.radius = 5;
  35. r1.length = 7;
  36. r1.width = 3;
  37. s1.length = 4;
  38. r2.length = 28;
  39. r2.width = 15;
  40. double yard = r2.length * r2.width;
  41. double cir=areacircle(c.radius);
  42. double rec=arearectangle(r1.length, r1.width);
  43. double sq=areasquare(s1.length);
  44. double garea = yard - (cir + rec + sq);
  45. cout << "The green color area is " << setiosflags(ios::fixed)
  46. << setprecision(2)<< garea;
  47. perirec( length, width);
  48. float peri = (length * 2) + (width * 2);
  49. cout << "Enter the cost per unit ";
  50. cin >> uni;
  51. cost = cost1(peri, uni);
  52. cout <<"THe total cost for the fence is "<< setiosflags(ios::fixed)
  53. << setprecision(2) << cost;
  54. }
  55.  
  56. double areacircle(float radius)
  57. {
  58. return 22 / 7 * radius*radius;
  59. }
  60. double arearectangle(float length, float width)
  61. {
  62. return length * width;
  63. }
  64. double areasquare(float slength)
  65. {
  66. return slength * slength;
  67. }
  68. void perirec(float &length, float &width)
  69. {
  70. cout << "Enter the length ";
  71. cin >> length;
  72. cout << "Enter the width ";
  73. cin >> width;
  74. }
  75. double cost1(float &peri, float uni)
  76. {
  77.  
  78. return uni * peri;
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement