Scientific Calculator Function

Scientific Calculator Function

Explore the advanced features and functions of a scientific calculator with this interactive tool.

Square Root Square Logarithm (base 10) Exponentiation Sine Cosine Tangent
function calculateScientific() { let inputValue = parseFloat(document.getElementById(‘input-value’).value); let operation = document.getElementById(‘operation’).value; let result = 0; if (isNaN(inputValue)) { alert(“Please enter a valid number.”); return; } switch (operation) { case ‘sqrt’: result = Math.sqrt(inputValue); break; case ‘square’: result = Math.pow(inputValue, 2); break; case ‘log’: result = Math.log10(inputValue); break; case ‘exp’: result = Math.exp(inputValue); break; case ‘sin’: result = Math.sin(inputValue); break; case ‘cos’: result = Math.cos(inputValue); break; case ‘tan’: result = Math.tan(inputValue); break; default: result = “Invalid operation”; } document.getElementById(‘result’).value = result; } function resetScientific() { document.getElementById(‘input-value’).value = ”; document.getElementById(‘result’).value = ”; document.getElementById(‘operation’).value = ‘sqrt’; }

Leave a Reply

Your email address will not be published. Required fields are marked *