@@ -1083,6 +1083,45 @@ <h4 style="font-size:160%;margin:7px">Trigonometry</h4>
10831083 < p style ="margin:12px; "> Area of a triangle:
10841084< br >
10851085< br >
1086+ < div >
1087+ < label style ="margin:12px; " for ="side1 "> Side 1:</ label >
1088+ < input id ="side1 " type ="number " value ="1 " step ="any " />
1089+ < br >
1090+ < label style ="margin:12px; " for ="side2 "> Side 2:</ label >
1091+ < input id ="side2 " type ="number " value ="1 " step ="any " />
1092+ < br >
1093+ < label style ="margin:12px; " for ="side3 "> Side 3:</ label >
1094+ < input id ="side3 " type ="number " value ="1 " step ="any " />
1095+
1096+ < script >
1097+ function triangleArea ( side1 , side2 , side3 , s ) {
1098+ return masth . sqrt ( s * ( s - side1 ) * ( s - side2 ) * ( s - side3 ) ) ;
1099+ }
1100+
1101+ function updateTriangleArea ( ) {
1102+ const side1 = parseFloat ( document . getElementById ( 'side1' ) . value ) ;
1103+ const side2 = parseFloat ( document . getElementById ( 'side2' ) . value ) ;
1104+ const side3 = parseFloat ( document . getElementById ( 'side3' ) . value ) ;
1105+ if ( isNaN ( side1 ) || isNaN ( side2 ) || isNaN ( side3 ) ) {
1106+ document . getElementById ( 'triangle-area' ) . innerText = '' ;
1107+ return ;
1108+ }
1109+
1110+ const s = side1 + side2 + side3 ;
1111+ const area = triangleArea ( side1 , side2 , side3 , s ) ;
1112+
1113+ document . getElementById ( 'triangle-area' ) . innerText =
1114+ `Area: ${ area . toFixed ( 5 ) } square units` ;
1115+ }
1116+
1117+ document . getElementById ( 'side1' ) . addEventListener ( 'input' , updateTriangleArea ) ;
1118+ document . getElementById ( 'side2' ) . addEventListener ( 'input' , updateTriangleArea ) ;
1119+ document . getElementById ( 'side3' ) . addEventListener ( 'input' , updateTriangleArea ) ;
1120+ </ script >
1121+ < p style ="margin:12px; " id ="triangle-area "> </ p >
1122+ </ div >
1123+ < br >
1124+ < br >
10861125< math xmlns ="http://www.w3.org/1998/Math/MathML ">
10871126 < mrow >
10881127 < mi > A</ mi >
0 commit comments