Solver Find the area of triangle if 3 sides are given
Algebra
->
Triangles
-> Solver Find the area of triangle if 3 sides are given
Log On
Geometry: Triangles
Geometry
Solvers
Solvers
Lessons
Lessons
Answers archive
Answers
Source code of 'Find the area of triangle if 3 sides are given'
This Solver (Find the area of triangle if 3 sides are given)
was created by by
hummingbird(0)
:
View Source
,
Show
,
Put on YOUR site
About hummingbird
:
==section input Input the following side lengths of the triangle: S1 = *[input s1=2],S2 = *[input s2=3]and S3 = *[input s3=4] Find the Area of the Triangle ==section solution perl my $d1 = $s1 +$s2; my $d2 = $s2 +$s3; my $d3 = $s3 +$s1; if($s1==0 || $s2==0 || $s3==0) { print " This is not a Triangle because atleast one of the side length is equal to zero. Please enter another set of values for S1,S2 and S3."; } elsif($d1==$s3 || $d2==$s1 || $d3==$s2) { print " This is not a Triangle because sum of two sides length is equal to the third side length. Please enter another set of values for S1,S2 and S3."; } else { if(($s1+$s2<$s3) || ($s2+$s3<$s1) || ($s1+$s3<$s2) ) { print " These sides do not form a triangle. Please enter another set of values for S1,S2 and S3. "; } else { my $s = 1/2*($s1+$s2+$s3); my $a=sqrt($s*($s-$s1)*($s-$s2)*($s-$s3)); print "In any triangle, If the side lengths are known then the area of the triangle can be calculated by the <A HREF=Heron%27s_formula.wikipedia>Heron's Formula</A>Heron's Formula. {{{A = sqrt(S*(S-S1)*(S-S2)*(S-S3))}}} Where {{{S = (S1+S2+S3)/2 }}} is the semi perimeter, or half of the triangle's perimeter. equivalent Heron's Formula is: {{{A= sqrt((s1+s2+s3)*(s1+s2-s3)*(s2+s3-s1)*(s1+s3-s2))/4}}} In our case the desired value is: {{{S = 1/2*($s1+$s2+$s3) = $s}}} {{{A = sqrt($s*($s-$s1)*($s-$s2)*($s-$s3)) = $a}}} So, the answer is that the Area of the Triangle with given parameter is $a . For more on this topic, refer to <A HREF=Triangle.wikipedia>Triangle</A> "; } } ==section output a, ==section check s1=4 s2=3 s3=5 a=3.464101615