diff --git a/Calculators/Pythagorus Calculator/Readme.md b/Calculators/Pythagorus Calculator/Readme.md new file mode 100644 index 00000000..a7a25a1f --- /dev/null +++ b/Calculators/Pythagorus Calculator/Readme.md @@ -0,0 +1,3 @@ +This is a pythagorus calculator, it takes two inputs from user from base, height and hypotenuse and gives the third value.
+It uses the well known theorem of Pythagorus theorem.
+e.g. hypotenuse^2 = base^2 + height^2 \ No newline at end of file diff --git a/Calculators/Pythagorus Calculator/index.html b/Calculators/Pythagorus Calculator/index.html new file mode 100644 index 00000000..64b4a1ae --- /dev/null +++ b/Calculators/Pythagorus Calculator/index.html @@ -0,0 +1,56 @@ + + + + + + + + + + + Pythagorus Calculator + + +
+

Pythagorus Calculator

+
+ +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +

Welcome to Pythagorus Calculator

+ + +
+ + + + \ No newline at end of file diff --git a/Calculators/Pythagorus Calculator/index.js b/Calculators/Pythagorus Calculator/index.js new file mode 100644 index 00000000..4c81ac48 --- /dev/null +++ b/Calculators/Pythagorus Calculator/index.js @@ -0,0 +1,40 @@ +let result=0; +let temp=0; +let btn=document.getElementById("calculate"); +btn.addEventListener("click",function(){ + let val1=document.getElementById("val1").value; + let val2=document.getElementById("val2").value; + let input1=document.getElementById("units1").value; + let input2=document.getElementById("units2").value; + if(input1!="hypotenuse" && input2!="hypotenuse"){ + result=Math.sqrt(Math.pow(val1,2)+Math.pow(val2,2)); + temp=1; + } + else if(input1=="hypotenuse" && (input2=="height" || input2=="base")){ + result=Math.sqrt(Math.pow(val1,2)-Math.pow(val2,2)); + } + else if(input2=="hypotenuse" && (input1=="height" || input1=="base")){ + result=Math.sqrt(Math.pow(val2,2)-Math.pow(val1,2)); + } + + if((input1=="height" || input2=="height") && (input1=="hypotenuse" || input2=="hypotenuse")) + temp=2; + if((input1=="base" || input2=="base") && (input1=="hypotenuse" || input2=="hypotenuse")) + temp=3; + + switch(temp){ + case 1: + document.getElementById("res").innerHTML="Hypotenuse is :"+result; + break; + case 2: + document.getElementById("res").innerHTML="Base is :"+result; + break; + case 3: + document.getElementById("res").innerHTML="Height is :"+result; + break; + default: + document.getElementById("res").innerHTML="Invalid Input"; + break; + }; +}); + diff --git a/Calculators/Pythagorus Calculator/style.css b/Calculators/Pythagorus Calculator/style.css new file mode 100644 index 00000000..6543a0cb --- /dev/null +++ b/Calculators/Pythagorus Calculator/style.css @@ -0,0 +1,42 @@ +body{ + text-align:center; + background-color:blanchedalmond; +} + +.button{ + display:block; + margin:20px auto; + width:50%; +} + +h1{ + margin:70px; + font-family:verdana; +} + +h3{ + margin-top:30px; + color:black; + font-size:15px; + font-family:verdana; +} + +input{ + width:200px; +} + +p{ + margin-top:40px; + font-family:verdana; + font-size:15px; + display:inline-block; +} + +section{ + margin:20px 0px; + display:inline-block; +} + +#res{ + display:inline-block; +} \ No newline at end of file