Saturday, 26 September 2015

RIGHT ANGLE TRIANGLES CALCULATOR CODE




-----------------------------------------------------------------------------------------------------------------
COPY AND PASTE BELOW CODE IN POST HTML SECTION
-----------------------------------------------------------------------------------------------------------------

<html>

<style type="text/css">
body {
font-family:arial;
padding:1em
}
form {
background:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIQ880_LgZX9_9VHMxBpmHB5STwjyeqBAd5QOCvHm0Ztkg0mLvVy3ilYPeH6q7PxAEvtbEkJoLJ3QOHqyDGm3ilz2qKo3-HtVBDoysqE3tcYVqkhjuzt7iUNapJ37EOCZxt_IKMZ7Sz3w4/w550-h250-no/11700798_449077528586911_7615001439496110272_n.png);
font-family:'Comic Sans MS';
font-weight:bold;
width:550px;
height:400px;
margin:1em 0
}
</style>

<head>

<title>Right-Angled Triangle Calculator</title>

<script type="text/javascript">
var StandardVal,NoOfSF,InputIs,OutputIs,ErrorIs,CountEnts,TypeIs,Msg,NumUnits=6,R2deg=180/Math.PI,D2rad=Math.PI/180;InValArray=new Array;OutArray=new Array;OutValArray=new Array;OrigsArray=new Array;
function GetInputs(){var OrigIs;CountEnts=0;TypeIs=0;InputIs=document.UniForm.Unit1.value;OrigIs=InputIs;InputIs=CutSpaces(InputIs);if(TestInput(InputIs)=="N"){return "N"}else{if(InputIs>0){InValArray[1]=InputIs;OrigsArray[1]=OrigIs;CountEnts++;TypeIs=TypeIs+1}}InputIs=document.UniForm.Unit2.value;OrigIs=InputIs;InputIs=CutSpaces(InputIs);if(TestInput(InputIs)=="N"){return "N"}else{if(InputIs>0){InValArray[2]=InputIs;OrigsArray[2]=OrigIs;CountEnts++;TypeIs=TypeIs+2}}InputIs=document.UniForm.Unit3.value;OrigIs=InputIs;InputIs=CutSpaces(InputIs);if(TestInput(InputIs)=="N"){return "N"}else{if(InputIs>0){InValArray[3]=InputIs;OrigsArray[3]=OrigIs;CountEnts++;TypeIs=TypeIs+4}}InputIs=document.UniForm.Unit4.value;OrigIs=InputIs;InputIs=CutSpaces(InputIs);if(TestInput(InputIs)=="N"){return "N"}else{if(InputIs>=90){ErrorIs=" Angle A must be less than 90 degrees. ";return "N"}if(InputIs>0){InValArray[4]=InputIs;OrigsArray[4]=OrigIs;CountEnts++;TypeIs=TypeIs+8}}InputIs=document.UniForm.Unit5.value;OrigIs=InputIs;InputIs=CutSpaces(InputIs);if(TestInput(InputIs)=="N"){return "N"}else{if(InputIs>=90){ErrorIs=" Angle B must be less than 90 degrees. ";return "N"}if(InputIs>0){InValArray[5]=InputIs;OrigsArray[5]=OrigIs;CountEnts++;TypeIs=TypeIs+16}}InputIs=document.UniForm.Unit6.value;OrigIs=InputIs;InputIs=CutSpaces(InputIs);if(TestInput(InputIs)=="N"){return "N"}else{if(InputIs>0){InValArray[6]=InputIs;OrigsArray[6]=OrigIs;CountEnts++;TypeIs=TypeIs+32}}if(CountEnts>2){ErrorIs=" ONLY TWO entries allowed. ";return "N"}if(CountEnts<2){ErrorIs=" TWO (non-zero) entries are needed. ";return "N"}return "Y"}
function CheckAnomalies(){switch(TypeIs){case 5:;if(eval(InValArray[3])<=eval(InValArray[1])){ErrorIs="  Hypotenuse (edge c) must be more than edge a  ";return "N"}else{break}case 6:;if(eval(InValArray[3])<=eval(InValArray[2])){ErrorIs="  Hypotenuse (edge c) must be more than edge b  ";return "N"}else{break}case 24:;var TotalAB=eval(InValArray[4])+eval(InValArray[5]);if(!(TotalAB==90)){ErrorIs=" Angle A + angle B must equal 90 degrees. ";return "N";}else{ErrorIs="2 angles will not do: some other size needed." ;return "N";}case 36:;if(Math.pow(InValArray[3],4)<16*Math.pow(InValArray[6],2)){ErrorIs=" Given conditions are impossible.  ";return "N"}else{break}}return "Y"}
function MakeStandardValues(){switch(TypeIs){case 3:;break;case 5:;InValArray[2]=Math.sqrt(Math.pow(InValArray[3],2)-Math.pow(InValArray[1],2));break;case 9:;InValArray[2]=InValArray[1]/Math.tan(InValArray[4]*D2rad);break;case 17:;InValArray[2]=InValArray[1]*Math.tan(InValArray[5]*D2rad);break;case 33:;InValArray[2]=2*InValArray[6]/InValArray[1];break;case 6:;InValArray[1]=Math.sqrt(Math.pow(InValArray[3],2)-Math.pow(InValArray[2],2));break;case 10:;InValArray[1]=InValArray[2]*Math.tan(InValArray[4]*D2rad);break;case 18:;InValArray[1]=InValArray[2]/Math.tan(InValArray[5]*D2rad);break;case 34:;InValArray[1]=2*InValArray[6]/InValArray[2];break;case 12:;InValArray[1]=InValArray[3]*Math.sin(InValArray[4]*D2rad);InValArray[2]=InValArray[3]*Math.cos(InValArray[4]*D2rad);break;case 20:;InValArray[1]=InValArray[3]*Math.cos(InValArray[5]*D2rad);InValArray[2]=InValArray[3]*Math.sin(InValArray[5]*D2rad);break;case 36:;InValArray[1]=Math.sqrt((Math.pow(InValArray[3],2)+Math.sqrt(Math.pow(InValArray[3],4)-16*Math.pow(InValArray[6],2)))/2);InValArray[2]=Math.sqrt(Math.pow(InValArray[3],2)-Math.pow(InValArray[1],2));break;case 40:;InValArray[1]=Math.sqrt((2*InValArray[6]*Math.sin(InValArray[4]*D2rad))/(Math.sin((90-InValArray[4])*D2rad)));InValArray[2]=2*InValArray[6]/InValArray[1];break;case 48:;InValArray[1]=Math.sqrt((2*InValArray[6]*Math.sin(InValArray[5]*D2rad))/(Math.sin((90-InValArray[5])*D2rad)));InValArray[2]=2*InValArray[6]/InValArray[1];break;}return "Y"}
function MakeOutputValues(){OutArray[1]=InValArray[1];OutArray[2]=InValArray[2];OutArray[3]=Math.sqrt(Math.pow(OutArray[1],2)+Math.pow(OutArray[2],2));OutArray[4]=Math.atan(OutArray[1]/OutArray[2])*R2deg;OutArray[5]=Math.atan(OutArray[2]/OutArray[1])*R2deg;OutArray[6]=OutArray[1]*OutArray[2]/2;}
function LoadOutputValues(){document.UniForm.Message.value="Adjust significant figs. OR click on [Clear All]";document.UniForm.Unit1.value=OutValArray[1];document.UniForm.Unit2.value=OutValArray[2];document.UniForm.Unit3.value=OutValArray[3];document.UniForm.Unit4.value=OutValArray[4];document.UniForm.Unit5.value=OutValArray[5];document.UniForm.Unit6.value=OutValArray[6];ValuesIn="Y"}
function RestoreOriginals(){switch(TypeIs){case 3:;document.UniForm.Unit1.value=OrigsArray[1];document.UniForm.Unit2.value=OrigsArray[2];return;case 5:;document.UniForm.Unit1.value=OrigsArray[1];document.UniForm.Unit3.value=OrigsArray[3];return;case 9:;document.UniForm.Unit1.value=OrigsArray[1];document.UniForm.Unit4.value=OrigsArray[4];return;case 17:;document.UniForm.Unit1.value=OrigsArray[1];document.UniForm.Unit5.value=OrigsArray[5];return;case 33:;document.UniForm.Unit1.value=OrigsArray[1];document.UniForm.Unit6.value=OrigsArray[6];return;case 6:;document.UniForm.Unit2.value=OrigsArray[2];document.UniForm.Unit3.value=OrigsArray[3];return;case 10:;document.UniForm.Unit2.value=OrigsArray[2];document.UniForm.Unit4.value=OrigsArray[4];return;case 18:;document.UniForm.Unit2.value=OrigsArray[2];document.UniForm.Unit5.value=OrigsArray[5];return;case 34:;document.UniForm.Unit2.value=OrigsArray[2];document.UniForm.Unit6.value=OrigsArray[6];return;case 12:;document.UniForm.Unit3.value=OrigsArray[3];document.UniForm.Unit4.value=OrigsArray[4];return;case 20:;document.UniForm.Unit3.value=OrigsArray[3];document.UniForm.Unit5.value=OrigsArray[5];return;case 36:;document.UniForm.Unit3.value=OrigsArray[3];document.UniForm.Unit6.value=OrigsArray[6];return;case 24:;document.UniForm.Unit4.value=OrigsArray[4];document.UniForm.Unit5.value=OrigsArray[5];return;case 40:;document.UniForm.Unit4.value=OrigsArray[4];document.UniForm.Unit6.value=OrigsArray[6];return;case 48:;document.UniForm.Unit5.value=OrigsArray[5];document.UniForm.Unit6.value=OrigsArray[6];return;}}
function CutSpaces(ThisInput){var ThisInput= ""+ThisInput;var Temp="";SplitString=ThisInput.split(" ");for (var i=0;i<SplitString.length;i++){Temp += SplitString[i];}while (Temp.charAt(0)=="0"){Temp=Temp.substring(1)}return Temp}
function TestInput(ToTest){var TestThis=""+ToTest,Allow="1234567890-.",IsAt;if (TestThis == "N"){ErrorIs=" All inputs MUST be numbers ";return "N"}for (var i=0;i<TestThis.length; i++){var CharIs=TestThis.charAt(i);IsAt=Allow.indexOf(CharIs);if (IsAt==-1){ErrorIs="One input NOT a valid number. ";return "N"}}var TestThis=Number(ToTest);if(isNaN(TestThis)){ErrorIs=" One input NOT a valid number. ";return "N"}if (TestThis > 1e9){ErrorIs=" One input TOO BIG! (> 1 000 000 000) ";return "N"}if (TestThis < 1e-5 && TestThis > 0){ErrorIs=" One input TOO SMALL! (< 0.000 01) ";return "N"}if (TestThis < 0){ErrorIs=" No input can be NEGATIVE! ";return "N"}return "Y";}
function ControlFormat(NumIs){var NumIs=Number(NumIs);if(Math.abs(NumIs)<1e-12){NumIs=0}if(NumIs == 0){return "0"}if(NumIs<0){NumIs=Math.abs(NumIs);var SignIs = "-";}else{var SignIs=""}  if(NumIs>1e15 ||  NumIs<1e-7){var Output1=MakeEnumber(NumIs);return SignIs + Output1;}else{var Output1=MakeSF(NumIs);var Output2=Format(Output1);return SignIs + Output2}}
function MakeEnumber(UseNum){var BaseIs,ExpIs,Shift,SignIs,IsE="N";var UseNum=""+UseNum;for(var i=0;i<UseNum.length;i++){ var CharIs=UseNum.charAt(i);if(CharIs=="e" || CharIs=="E"){IsE="Y";break}}if(IsE=="Y"){BreakUp=UseNum.split("e");ExpIs=BreakUp[1];if(eval(ExpIs)<0){SignIs="-"}else{SignIs="+"}ExpIs=Math.abs(Number(ExpIs));BaseIs=MakeSF(BreakUp[0]);if(eval(BaseIs)==10){BaseIs="1";if(SignIs=="-"){ExpIs=ExpIs-1}else{ExpIs=ExpIs+1}}ExpIs=SignIs+ExpIs;UseNum=BaseIs+"  "+"e"+ExpIs;}else{ExpIs=0;while(UseNum>10){UseNum=UseNum/10;ExpIs++;Shift="e+"}while(UseNum<1){UseNum=UseNum*10;ExpIs++;Shift="e-"}BaseIs=MakeSF(UseNum);if(eval(BaseIs)==10){BaseIs="1";ExpIs=ExpIs+1}UseNum=BaseIs+"  "+Shift+ExpIs}return UseNum}
function MakeSF(UseNum){var CountE=0,Shift="";var UseNum=Number(UseNum);var AllowError=1e-10;if(Math.abs(UseNum)<AllowError){return 0}if(Math.abs(UseNum-1)<AllowError){return 1}if(Math.abs(UseNum-10)<AllowError){return 10}if(Math.abs(UseNum-100)<AllowError){return 100}if(Math.abs(UseNum-1000)<AllowError){return 1000}if(UseNum>1 && UseNum<10){CountE=0;Shift="N"}while(UseNum>10){UseNum=UseNum/10;CountE++;Shift="L"}while(UseNum<1){UseNum=UseNum*10;CountE++;Shift="R"}for(var i=0;i<NoOfSF-1; i++){ UseNum=UseNum*10}UseNum=Math.round(UseNum);UseNum=""+UseNum;var NumLength=UseNum.length;if(NumLength>NoOfSF){CountE=CountE+1;if(Shift=="R"){Shift="X"}}var BuildNumber="",NextDigit="";if(Shift=="N"){for(var i=0; i<NumLength;i++){NextDigit=UseNum.charAt(i);BuildNumber=BuildNumber+NextDigit;if(i==CountE){BuildNumber=BuildNumber + "."}}}if(Shift=="L"){for(var i=0;i<NumLength;i++){NextDigit=UseNum.charAt(i);BuildNumber=BuildNumber+NextDigit;if(i==CountE){BuildNumber=BuildNumber+"."}}while(i<CountE+1){BuildNumber=BuildNumber+"0";i++}}if(Shift=="R" && CountE<13){BuildNumber="0.";for(var i=0;i<CountE-1;i++){BuildNumber=BuildNumber+"0"}BuildNumber=BuildNumber+UseNum.charAt(0);for(var i=1;i<NumLength;i++){BuildNumber=BuildNumber+UseNum.charAt(i)}}if(Shift=="X" && CountE<13){if(CountE==2){BuildNumber="1"}else{  BuildNumber="0.";for(var i=3;i<CountE;i++){ BuildNumber=BuildNumber+"0"}BuildNumber=BuildNumber+"1"}}var DPisAt=BuildNumber.indexOf(".");if(DPisAt>0){while(BuildNumber.length>DPisAt){if(BuildNumber.charAt(BuildNumber.length-1)=="0"){BuildNumber=BuildNumber.substring(0,BuildNumber.length-1)}else{break}}}if(BuildNumber.charAt(BuildNumber.length-1)=="."){BuildNumber=BuildNumber.substring(0,BuildNumber.length-1)}return BuildNumber}
function Format(NumToDo){NumToDo=""+NumToDo;TestForSize=Number(NumToDo);if(TestForSize>1e15 || TestForSize<1e-10){return NumToDo}var DPisAt=NumToDo.indexOf(".");if(DPisAt>0){while(NumToDo.length>DPisAt){if (NumToDo.charAt(NumToDo.length-1)=="0"){NumToDo=NumToDo.substring(0,NumToDo.length-1) }else{break}}}if (NumToDo.charAt(NumToDo.length-1)=="."){NumToDo=NumToDo.substring(0,NumToDo.length-1)}var DPisAt=NumToDo.indexOf(".");if (DPisAt==-1){DPisAt=999}var NumLength=NumToDo.length;if(DPisAt<NumLength){var LenLeft=DPisAt;var LenRight=NumLength-DPisAt}else{var LenLeft=NumLength;var LenRight=0}var LeftStr=NumToDo.substring(0, LenLeft);var RightStr=NumToDo.substring(LenLeft+1);var Separator=" ";var NewLeft="";var Count=0;for(var i=LenLeft-1;i >= 0; i--){NextDigit=LeftStr.charAt(i);NewLeft=""+NextDigit+NewLeft;Count++;if(Count>0 && Count % 3 == 0 && !(Count==LenLeft)){NewLeft=Separator+NewLeft}}var NewRight="";var Count=0;for(var i=0;i<LenRight;i++){NextDigit=RightStr.charAt(i);NewRight=NewRight+NextDigit;Count++;if(Count>0 && Count % 3 == 0 && !(Count==LenRight-1)){NewRight=NewRight+Separator}}if(LenRight==0){return NewLeft}if(LenLeft==0){return "0."+NewRight}return NewLeft+"."+NewRight;}
function StartUp(){ClearAll();document.UniForm.Message.value="Type sizes in any TWO empty boxes, then click on [Calculate It]";return}
function ClearAll(){for(var i=0;i < NumUnits+1;i++){OutValArray[i]=""}for(var i=0;i < NumUnits+1;i++){OrigsArray[i]=""}LoadOutputValues();ValuesIn="N";return}
function AdjustOutputValues(){NoOfSF=document.UniForm.SigFigs.selectedIndex;NoOfSF=NoOfSF+3;if(NoOfSF<3){NoOfSF=3}if(NoOfSF > 9){NoOfSF=9}for (var i=0; i < NumUnits+1;i++){var Output=ControlFormat(OutArray[i]);OutValArray[i] = Output;}LoadOutputValues();RestoreOriginals();return}
function CalculateIt(){if(ValuesIn=="Y"){AdjustOutputValues(); return}if(GetInputs()=="N"){document.UniForm.Message.value=ErrorIs+" Click on [Clear All]";return}if(CheckAnomalies()=="N"){document.UniForm.Message.value=ErrorIs+" Click on [Clear All]";return}if(MakeStandardValues()=="N"){document.UniForm.Message.value=ErrorIs+" Click on [Clear All]";return}MakeOutputValues();AdjustOutputValues();return}
</script>

</head>

<body bgcolor="000000" onload="StartUp()" text="000000"><center>
<tr align="CENTER"><td>
<span style="color: red; font-size: large;"><b>The Right-angled Triangles Calculator</b></span><hr noshade="" size="5" />
<form name="UniForm">
<table border="0">
<tr align="CENTER"><td>
<br />
<br />
<input name="Message" onfocus="this.blur()" size="70" type="TEXT" value="" /></td></tr>
<tr>
<td align="RIGHT"><b>Show values to . . .
<select name="SigFigs" onchange="CalculateIt(99)" size="1">
<option value="0">3
<option value="1">4
<option value="2">5
<option value="3">6
<option value="4">7
<option value="5">8
<option value="6">9
</option></option></option></option></option></option></option></select>significant figures</b>.</td></tr>
<table border="0" cellpadding="5">
<tr><td align="left"><span style="font-family: ARIAL;"><span style="font-size: xx-small;">edge</span> <span style="color: red;"><b><i>a</i></b></span> =</span></td><td><input maxlength="20" name="Unit1" size="20" type="TEXT" value=" " /></td><td align="LEFT"><span style="font-size: xx-small;"><i>units</i></span></td><td><input onclick="CalculateIt()" type="BUTTON" value="[ Calculate It ]" /></td></tr>
<tr><td align="RIGHT"><span style="font-family: ARIAL;"><span style="font-size: xx-small;">edge</span> <span style="color: red;"><b><i>b</i></b></span> =</span></td><td><input maxlength="20" name="Unit2" size="20" type="TEXT" value=" " /></td><td align="LEFT"><span style="font-size: xx-small;"><i>units</i></span></td>
<td rowspan="4" valign="CENTER"><img alt="Right Triangle" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-u15QOmW37RnQa5bAvNiMNblbmDNktVitsLK-1EvPqumfMV7y47IEFi3Z8gG9bv8u1nG_W7_ih5k2cxXjn99nosln-kXfomKOesGilqcmn7adhnKBgxHDjoEr3SCngBUSgSQDG44iWYe9/s1600/arittri.gif" /></td></tr>
<tr><td align="RIGHT"><span style="font-family: ARIAL;"><span style="font-size: xx-small;">edge</span> <span style="color: red;"><b><i>c</i></b></span> =</span></td><td><input maxlength="20" name="Unit3" size="20" type="TEXT" value=" " /></td><td align="LEFT"><span style="font-size: xx-small;"><i>units</i></span></td></tr>
<tr><td align="RIGHT"><span style="font-family: ARIAL;"><span style="font-size: xx-small;">angle</span> <b>A</b> =</span></td><td>
<input maxlength="20" name="Unit4" size="20" type="TEXT" value=" " /></td><td align="LEFT"><span style="font-size: xx-small;"><i>degrees</i></span></td></tr>
<tr><td align="RIGHT"><span style="font-family: ARIAL;"><span style="font-size: xx-small;">angle</span> <b>B</b> =</span></td><td>
<input maxlength="20" name="Unit5" size="20" type="TEXT" value=" " /></td><td align="LEFT"><span style="font-size: xx-small;"><i>degrees</i></span></td></tr>
<tr><td align="RIGHT"><span style="font-family: ARIAL;"><b>area</b> =</span></td><td>
<input maxlength="20" name="Unit6" size="20" type="TEXT" value=" " /></td><td align="LEFT"><span style="font-size: xx-small;"><i>square units</i></span></td><td><input onclick="StartUp()" type="BUTTON" value="[ Clear All ]" /></td></tr>
</table>
</table>
</form>
</td></tr>
</center>
</body>
</html>

0 comments:

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

FB Gadgets | Template Designed by Fatakat PhotosCoolBThemes.com
Code by : paid web directory

https://www.google.co.uk/search?q=site%3Ablogspot.com+fbgadgets