{"id":1345,"date":"2016-06-21T09:43:06","date_gmt":"2016-06-21T09:43:06","guid":{"rendered":"http:\/\/www.testingdocs.com\/questions\/?p=1345"},"modified":"2021-03-21T10:00:52","modified_gmt":"2021-03-21T10:00:52","slug":"calculate-third-side-of-triangle-puzzle","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/calculate-third-side-of-triangle-puzzle\/","title":{"rendered":"Calculate Third side of Triangle puzzle?"},"content":{"rendered":"<p>Given two sides with length 7 cm and 9 cm and angle between them is 25 degrees. Calculate the third side length of the triangle.<\/p>\n<h3><strong>Solution:<\/strong><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1561\" src=\"http:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Triangle-with-known-sides-a-and-b.png\" alt=\"Triangle with known sides a and b\" width=\"974\" height=\"578\" title=\"\"><\/p>\n<h3><strong>Mathematical proof:<\/strong><\/h3>\n<p>Based on the data given , you can calculate the height of the triangle as shown in the above figure.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/latex.codecogs.com\/gif.latex?\\LARGE&amp;space;h&amp;space;=&amp;space;asin\\Theta\" alt=\"\\LARGE h = asin\\Theta\" align=\"absmiddle\" title=\"\"><\/p>\n<p>&nbsp;<\/p>\n<p>b side can be split into acos\u03b8 and b- acos\u03b8<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/latex.codecogs.com\/gif.latex?\\LARGE&amp;space;b&amp;space;=&amp;space;acos\\Theta&amp;space;+&amp;space;(b&amp;space;-&amp;space;acos\\Theta&amp;space;)\" alt=\"\\LARGE b = acos\\Theta + (b - acos\\Theta )\" align=\"absmiddle\" title=\"\"><\/p>\n<p>&nbsp;<\/p>\n<p>Applying law of right angled triangle<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/latex.codecogs.com\/gif.latex?\\LARGE&amp;space;c^{2}&amp;space;=&amp;space;a^2sin^{2}\\Theta&amp;space;+&amp;space;(b-acos\\Theta&amp;space;)^2\" alt=\"\\LARGE c^{2} = a^2sin^{2}\\Theta + (b-acos\\Theta )^2\" align=\"absmiddle\" title=\"\"><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Expanding the terms we get:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/latex.codecogs.com\/gif.latex?\\LARGE&amp;space;c^{2}&amp;space;=&amp;space;a^2sin^{2}\\Theta&amp;space;+&amp;space;b^2&amp;space;+&amp;space;a^2cos^2\\Theta&amp;space;-&amp;space;2abcos\\Theta\" alt=\"\\LARGE c^{2} = a^2sin^{2}\\Theta + b^2 + a^2cos^2\\Theta - 2abcos\\Theta\" align=\"absmiddle\" title=\"\"><\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/latex.codecogs.com\/gif.latex?\\LARGE&amp;space;a^{2}&amp;space;=&amp;space;a^2sin^{2}\\Theta&amp;space;+&amp;space;a^2cos^2\\Theta\" alt=\"\\LARGE a^{2} = a^2sin^{2}\\Theta + a^2cos^2\\Theta\" align=\"absmiddle\" title=\"\"><\/p>\n<p>&nbsp;<\/p>\n<p>Replace the terms, we get:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/latex.codecogs.com\/gif.latex?\\LARGE&amp;space;c^{2}&amp;space;=&amp;space;a^2&amp;space;+&amp;space;b^2&amp;space;-2abcos\\Theta\" alt=\"\\LARGE c^{2} = a^2 + b^2 -2abcos\\Theta\" align=\"absmiddle\" title=\"\"><\/p>\n<p>&nbsp;<\/p>\n<h3><strong>Java Program<\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.testingdocs.examples;\r\n\r\npublic class TriangleThirdSide {\r\n double a;\r\n double b;\r\n double angle;\r\n\r\npublic TriangleThirdSide(double a, double b, double angle) {\r\n this.a=a;\r\n this.b=b;\r\n this.angle=angle * Math.PI \/180;\r\n }\r\n\r\npublic double findC() {\r\n return Math.sqrt( a*a + b*b - (2*a*b* Math.cos(angle)));\r\n\r\n}\r\n\r\npublic static void main(String[] args) {\r\n TriangleThirdSide triangle= new TriangleThirdSide(7.0,9.0,25.0);\r\n double c = triangle.findC();\r\n System.out.println(\"Third side of the Triangle = \"+ String.format( \"%.2f\", c ) + \" cm\");\r\n }\r\n\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Answer:<\/p>\n<p>Third side of the Triangle = 3.98 cm<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">public TriangleThirdSide(double a, double b, double angle) {\r\n this.a=a;\r\n this.b=b;\r\n this.angle=angle * Math.PI \/180; \r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>The class constructor takes the values of known sides a , b and the angle between the sides i.e \u03b8 . We can create a new Triangle using the new operator as shown below:<\/p>\n<p>Example : new TriangleThirdSide(7.0,9.0,25.0);<\/p>\n<p>Method findC() calculates the third side using the mathematical proof and the formula shown above.<\/p>\n<!--themify_builder_content-->\n<div id=\"themify_builder_content-1345\" data-postid=\"1345\" class=\"themify_builder_content themify_builder_content-1345 themify_builder tf_clear\">\n    <\/div>\n<!--\/themify_builder_content-->\n","protected":false},"excerpt":{"rendered":"<p>Given two sides with length 7 cm and 9 cm and angle between them is 25 degrees. Calculate the third side length of the triangle. Solution: Mathematical proof: Based on the data given , you can calculate the height of the triangle as shown in the above figure. &nbsp; b side can be split into [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1345","post","type-post","status-publish","format-standard","hentry","category-automation","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=1345"}],"version-history":[{"count":2,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1345\/revisions"}],"predecessor-version":[{"id":19850,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1345\/revisions\/19850"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=1345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=1345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=1345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}