Git Product home page Git Product logo

calculator's Introduction

Calculator

This is a basic calculator web application that allows users to perform arithmetic calculations. It provides a user-friendly interface with buttons for inputting numbers, operators, and parentheses.

Features

  • Input field to display the result of calculations
  • Buttons for numbers (0-9), decimal point, operators (+, -, *, /), and parentheses (() and ))
  • AC button to clear the input field
  • C button to delete the last character
  • = button to evaluate the expression and display the result
  • Error handling for invalid expressions

Technologies Used

  • HTML: Markup language for creating the calculator interface
  • CSS: Styling language for visually enhancing the calculator
  • JavaScript: Programming language for implementing calculator functionality
  • Math.js: Library for evaluating mathematical expressions

Usage

To use the calculator, simply open the index.html file in a web browser. You can enter numbers and perform calculations by clicking on the buttons provided. The result will be displayed in the input field.

Code Explanation

The project consists of three main files:

  1. index.html: Contains the HTML structure of the calculator interface and includes the necessary CSS and JavaScript files.
  2. style.css: Defines the visual styles for the calculator interface, including colors, dimensions, and positioning.
  3. script.js: Implements the JavaScript functions that handle user interactions and perform the calculations.

The JavaScript functions included in script.js are:

  • appendValue: Appends the clicked button value to the current expression in the input field.
  • appendOperator: Appends the clicked operator to the current expression, handling certain validation rules.
  • clearResult: Clears the input field and resets the current expression.
  • deleteLastChar: Deletes the last character from the current expression.
  • calculate: Evaluates the current expression using the eval function and displays the result in the input field.
  • calculateEquation: Evaluates the current expression using the math.evaluate function from Math.js and displays the result in the input field.
  • solveAlgebra: Simplifies the current algebraic expression using the math.simplify function from Math.js and displays the result in the input field.

Credits

The project utilizes the following external resources:

  • Google Fonts: Provides a wide range of fonts for the calculator interface.
  • Math.js: Library for mathematical calculations and algebraic simplification.

License

This project is licensed under the MIT License.

calculator's People

Contributors

veeramanikandanr48 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.