A sleek and modern calculator application inspired by the Samsung Calculator. This project replicates the functionality and design of the Samsung Calculator, offering a user-friendly interface with advanced features like parentheses, percentage calculations, and error handling.
- Basic Arithmetic Operations: Addition, subtraction, multiplication, and division.
- Parentheses Support: Easily manage complex calculations with nested parentheses.
- Percentage Calculations: Quickly calculate percentages with the dedicated
%button. - Error Handling: Displays error messages for invalid operations (e.g., division by zero).
- Negative Numbers: Toggle between positive and negative numbers using the
+/-button. - Decimal Point: Supports decimal calculations with the
.button. - Clear and Delete: Clear the entire display with
Cor delete the last character with⌫. - Responsive Design: Fully responsive layout that works on both mobile and desktop screens.
- Aesthetic Design: Clean and modern UI with smooth animations and green accents.
- Parentheses Logic: Automatically handles opening and closing parentheses, ensuring balanced expressions.
- Operator Precedence: Follows standard mathematical rules for operator precedence (PEMDAS/BODMAS).
- Real-time Display: Shows the current calculation with a blinking green cursor.
- Error Popup: Displays a temporary error message for invalid operations (e.g., division by zero).
- Color-coded Operators: Operators (
+,-,×,÷) are highlighted in green for better visibility. - Parentheses Highlighting: The last pair of parentheses is highlighted in green for clarity.
-
Basic Calculations:
- Enter numbers using the numeric buttons (
0-9). - Use the operator buttons (
+,-,×,÷) to perform calculations. - Press
=to get the result.
- Enter numbers using the numeric buttons (
-
Parentheses:
- Use the
()button to add parentheses for complex calculations. - The calculator automatically balances parentheses and highlights the last pair in green.
- Use the
-
Percentage Calculations:
- Enter a number and press
%to calculate its percentage. - For example,
50 %will display0.5.
- Enter a number and press
-
Negative Numbers:
- Use the
+/-button to toggle between positive and negative numbers.
- Use the
-
Decimal Point:
- Use the
.button to add decimal points for precise calculations.
- Use the
-
Clear and Delete:
- Press
Cto clear the entire display. - Press
⌫to delete the last character.
- Press
-
Error Handling:
- If an invalid operation is performed (e.g., division by zero), an error message will pop up temporarily.
To run this project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/ayoubchemli/samsung-calculator.git
-
Navigate to the project directory:
cd samsung-calculator -
Open the
index.htmlfile in your browser:open index.html
- HTML5: For structuring the calculator interface.
- CSS3: For styling and animations, including the green cursor and operator highlighting.
- JavaScript: For handling calculations, parentheses logic, and error handling.
Contributions are welcome! If you'd like to improve this project, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeatureName). - Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/YourFeatureName). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Enjoy calculating with this Samsung-inspired calculator! 🚀
