calculator This is a simple calculator application built using the tkinter library in html, css and javaScript. It provides basic arithmetic operations and some mathematical functions like cos, sin functions, subraction, and Addition.
Features Addition, subtraction, multiplication, and division operations Trigonometric functions: sin, cos, tan Logarithm with a specified base Square root calculation Clearing the input field Deleting the last character Constants: Euler's number (e) and pi (π)
Usage Clone the repository or download the calculator.html file. Run the calculator.html file using javaScript. The calculator window will appear with a text input field and buttons for different operations. Enter the numbers and perform calculations using the buttons. Press the "=" button to get the result. Use the other buttons to perform additional operations as needed.
<style> form{ width:440px; padding:25px; margin:auto; border:5px solid #aaa; border-radius:15px 15px; }input{
background:#888;
color:#fff;
font-size:15px;
padding-top:15px;
padding-bottom:15px;
padding-left:19px;
padding-right:19px;
margin:6px;
}
h2{
text-align:center;
}
.sc{
background:#fff;
color:#000;
}
function cos(form) { form.display.value = Math.cos(form.display.value); }
function sin(form) { form.display.value = Math.sin(form.display.value); }
function tan(form) { form.display.value = Math.tan(form.display.value); }
function sqrt(form) { form.display.value = Math.sqrt(form.display.value); }
function ln(form) { form.display.value = Math.log(form.display.value); }
function exp(form) { form.display.value = Math.exp(form.display.value); }
function deleteChar(input) { input.value = input.value.substring(0, input.value.length - 1) }
function changeSign(input) { if(input.value.substring(0, 1) == "-") input.value = input.value.substring(1, input.value.length) else input.value = "-" + input.value }
function compute(form) { form.display.value = eval(form.display.value) }
function square(form) { form.display.value = eval(form.display.value) * eval(form.display.value) }
function checkNum(str) { for (var i = 0; i < str.length; i++) { var ch = str.substring(i, i+1) if (ch < "0" || ch > "9") { if (ch != "/" && ch != "*" && ch != "+" && ch != "-" && ch != "." && ch != "(" && ch!= ")") { alert("invalid entry!") return false } } } return true } </script>
