Skip to content

balajis183/arithmetic-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Calculator Application

This project is a modern and interactive calculator built with HTML, CSS, and JavaScript. The application demonstrates essential web development concepts, including layout design, styling, and interactive functionality, making it an excellent example for educational or practical purposes.


Features

1. User-Friendly Interface

  • Simple and intuitive design, making it easy to perform basic arithmetic operations.
  • Buttons are arranged systematically for quick access.

2. Responsive Layout

  • The calculator uses a grid layout that adapts to various screen sizes, ensuring usability on both desktop and mobile devices.

3. Dynamic Scrolling Title

  • The calculator features a scrolling title using the <marquee> tag, adding a touch of animation to the interface.

4. Interactive Buttons

  • Each button has hover and active effects for a responsive and interactive user experience.

Technical Overview

HTML Structure

The HTML provides the structural foundation of the calculator:

  • Input Field: Displays the current input and results.
  • Buttons: Arranged for numbers, operators, and utility functions like clear and equals.
  • Marquee Tag: Displays a dynamic scrolling "Calculator" title.

CSS Styling

The design leverages modern CSS features for a polished look:

  • Grid Layout: The grid-template-columns property ensures a neat arrangement of buttons.
  • Styling Effects:
    • Buttons have smooth hover transitions.
    • Box shadows and rounded corners create a professional appearance.
  • Responsive Design: Ensures the layout scales well across devices.

JavaScript Functionality

JavaScript handles all interactivity and calculations:

  • Input Handling: Numbers and operators are appended to the display when clicked.
  • Evaluation:
    • The eval() function processes the mathematical expression and returns the result.
    • Example: Input "2 + 3 * 4" evaluates to 14 (follows operator precedence).
  • Clear Functionality: Clears the input field with a single button click.
  • Error Handling: Displays "Arithmetic Error" for invalid expressions.

How It Works

Grid Layout for Buttons

The calculator’s buttons are arranged using a CSS grid:

  • grid-template-columns: repeat(4, 1fr) divides the layout into four equal columns.
  • This ensures consistent alignment of buttons and input fields.

eval() for Calculations

The eval() function dynamically evaluates a string-based mathematical expression. While efficient, it should be used cautiously due to potential security risks in production environments.

Interactive Feedback

Buttons respond to user actions with:

  • Hover Effects: Change background color for visual feedback.
  • Active States: Simulate button presses with darker shades.

Technologies Used

  • HTML: For structure and layout.
  • CSS: For styling and design.
  • JavaScript: For dynamic interactivity and functionality.

Setup Instructions

  1. Clone the repository using the command below:

    git clone https://github.com/balajis183/arithmetic-calculator.git
  2. Navigate to the project directory:

    cd arithmetic-calculator
  3. Open the index.html file in any modern web browser.

  4. Use the calculator to perform basic arithmetic operations.

    • 4a. Use the buttons to enter numbers and operators.
    • 4b. Click = to get the result, or C to clear the input.

Future Enhancements

  • Improved Theming: Add light and dark mode options.
  • Keyboard Support: Allow users to use their keyboard for inputs.
  • Advanced Features: Include scientific calculator functions like square roots and percentages.
  • Modern Animation: Replace the <marquee> tag with CSS animations for a more modern look.

Conclusion

This project highlights the core concepts of web development by combining structure (HTML), style (CSS), and interactivity (JavaScript). It is a great starting point for beginners and a useful reference for developers looking to build functional web applications.

Feel free to connect with me:

Thank you for exploring My calculator! 😊

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published