This is a simple calculator application built using HTML, CSS, and JavaScript. It supports basic arithmetic operations (addition, subtraction, multiplication, division) as well as advanced functions such as square root calculation.
-
Basic Arithmetic Operations:
- Addition (
+) - Subtraction (
-) - Multiplication (
*) - Division (
/)
- Addition (
-
- Square root calculation (
√)
- Square root calculation (
-
- Clear input (
AC) - Delete one character (
DE) - Prevents division by zero errors
- Toggle visibility of advanced operations using the "more" button
- Responsive button size change when more options are shown or hidden
- Clear input (
-
- Numbers, operators (
+,-,*,/) - Decimal point (
.) - Enter (
=) to calculate - Backspace (
DE) to delete one character - Escape (
AC) to clear the display rkey for square root
- Numbers, operators (
index.html: The HTML structure of the calculatorstyle.css: The styling for the calculatorscript.js: The JavaScript logic for performing calculations (included in the HTML file as an inline script)
- Download the project files or clone the repository.
- Open the
index.htmlfile in your browser.
- AC is used to Clears all inputs
- DE is used Deletes the last entered character
- +, -,*, / is used to Basic operators
- 00,0 - Number inputs
- . is used for Decimal point for floating-point calculations
- = ise used to Performs the calculation based on the input
- √ is used to Calculates the square root of the current input
- more is used to Toggles the square root function button visibility
addInput(char): Adds a character to the display (handles operator restrictions).deleteOne(): Deletes the last character in the input.deleteAll(): Clears the entire input.calculate(): Evaluates the input expression and handles errors like division by zero.calculateSquareRoot(): Evaluates the square root of the current input.toggleMore(): Toggles the visibility of the square root button and adjusts the size of other buttons.
-
- The calculator is centered in the screen with a responsive design.
- Button styles include shadows for a 3D effect and smooth hover transitions.
-
- Used to show/hide additional functionality (square root).
- When additional options are shown, button sizes are adjusted dynamically.
This project is open-source and free to use.