A sleek, responsive calculator web application built with HTML, CSS, and JavaScript. This calculator provides a user-friendly interface with both mouse and keyboard support for performing basic mathematical operations.
- Addition (+)
- Subtraction (-)
- Multiplication (×)
- Division (/)
- Percentage (%)
- Decimal numbers support
- Clean, modern design with a responsive layout
- Color-coded buttons for better user experience
- Blue: Operators (+, -, ×, ÷)
- Red: Special functions (AC, DEL)
- Green: Equals button (=)
- Gray: Numbers and decimal point
- Smooth animations and hover effects
- Expression history display
- Error handling for invalid expressions
- Expression history tracking
- Automatic decimal point handling
- Proper percentage calculations
- Number formatting for cleaner results
- Prevention of invalid operations
The calculator can be operated using your keyboard:
- Numbers (0-9) for digit input
- Operators (+, -, *, /)
- Enter or = for calculation
- Backspace for delete
- Escape for clear all
- Decimal point (.)
- Percentage symbol (%)
Calculator/
│
├── index.html # Main HTML file
├── style.css # CSS styling
└── README.md # Documentation
- HTML5
- CSS3 (with Grid and Flexbox)
- Vanilla JavaScript
- Responsive Design
- CSS Transitions for animations
-
Display System
- Main display for current input
- History display for previous calculations
-
Button Grid
- 4x5 grid layout
- Special sizing for zero button (spans 2 columns)
-
JavaScript Functions
appendValue(): Handles number and operator inputclearDisplay(): Resets the calculatordeleteLast(): Removes the last entered charactercalculate(): Processes and evaluates the expression
The calculator is fully responsive and works on:
- Desktop computers
- Tablets
- Mobile phones
- Different screen sizes and orientations
Works on all modern browsers:
- Google Chrome
- Mozilla Firefox
- Microsoft Edge
- Safari
- Opera
-
Opening the Calculator:
- Open
index.htmlin any modern web browser
- Open
-
Performing Calculations:
- Click buttons or use keyboard for input
- Use AC to clear all
- Use DEL to remove last entry
- Press = or Enter to calculate
-
Using Percentages:
- Enter a number
- Press % to convert to percentage
- Continue with other operations if needed
- Edit
index.htmlfor structure changes - Modify
style.cssfor styling updates - Update JavaScript code in
index.htmlfor functionality changes
- Semantic HTML5 elements
- CSS Grid for layout
- Event delegation for buttons
- Error handling for calculations
- Input validation
- Responsive design principles
Possible improvements that could be added:
- Scientific calculator functions
- History log of calculations
- Memory functions (M+, M-, MR, MC)
- Theme switcher (Light/Dark mode)
- Keyboard shortcuts customization
This project is open source and available under the MIT License.
[Your Name]
- Student ID: 1SI24CS189
- Course: Computer Science Engineering
- Institution: [Your Institution Name]
Feel free to contribute to this project by submitting issues or pull requests!
