Calculator to Perform Scientific Calculations

Scientific Calculator for Students

function performCalculation() { const expression = document.getElementById(‘inputExpression’).value; try { const result = eval(expression); document.getElementById(‘outputResult’).value = result; } catch (error) { document.getElementById(‘outputResult’).value = ‘Error’; } } function clearCalculator() { document.getElementById(‘inputExpression’).value = ”; document.getElementById(‘outputResult’).value = ”; } .calculator-container { background-color: #f0f0f0; padding: 20px; max-width: 400px; margin: 50px auto; border-radius: 8px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); font-family: Arial, sans-serif; } .calculator-header h2 { text-align: center; margin-bottom: 20px; } .calculator-inputs, .calculator-output { margin-bottom: 15px; } .calculator-inputs label, .calculator-output label { display: block; font-weight: bold; margin-bottom: 5px; } .calculator-inputs input, .calculator-output input { width: 100%; padding: 10px; font-size: 16px; border: 1px solid #ccc; border-radius: 5px; } .calculator-buttons { display: flex; justify-content: space-between; } .calculator-buttons button { background-color: #0093da; color: #fff; padding: 10px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; width: 48%; } .calculator-buttons button:hover { background-color: #007bb5; }

Leave a Reply

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