Skip to content

This PHP Calculator is a simple yet powerful tool for performing basic arithmetic operations. Built using PHP, it offers a user-friendly interface and efficient calculation capabilities. Whether you need to add, subtract, multiply, or divide, this calculator provides a reliable solution for your mathematical needs.

Notifications You must be signed in to change notification settings

Allanotieno254Backup/calculator-using-php

Repository files navigation

calculator-using-php

Scientific Calculator

This project is a web-based scientific calculator built using PHP, JavaScript, HTML, and CSS. The calculator supports basic arithmetic operations (addition, subtraction, multiplication, division), as well as advanced mathematical functions like exponentiation, square roots, logarithms, and percentages.

Features

Basic Arithmetic Operations: Addition, Subtraction, Multiplication, Division Advanced Functions: Exponentiation, Square Root, Logarithm, Percentage User-friendly Interface Responsive Design

Directory Structure

calculator/ │ ├── index.php ├── calculate.php ├── addition.php ├── subtraction.php ├── multiplication.php ├── division.php ├── exponentiation.php ├── sqrt.php ├── logarithm.php ├── percentage.php ├── styles.css ├── scripts.js └── README.md

Installation

1. Clone the repository:

git clone https://github.com/Allanotieno254Backup/calculator-using-php

2. Navigate to the project directory:

cd calculator

Set up a local web server:

If you are using XAMPP, move the project folder to the htdocs directory. mv calculator /path/to/xampp/htdocs/

Start the web server:

Open XAMPP and start the Apache server. Access the calculator: Open your web browser and navigate to http://localhost/calculator.

Usage

Basic Arithmetic: Use the buttons on the calculator interface to perform addition (+), subtraction (-), multiplication (*), and division (/).

Advanced Functions:

· Use the ^ button for exponentiation. · Use the √ button for square roots. · Use the log button for logarithms (base 10). · Use the % button to calculate percentages.

Clear and Delete:

· Use the C button to clear the display. · Use the DEL button to delete the last character.

File Descriptions

index.php The main entry point of the calculator. It includes the form for user input and the display area. It also contains the JavaScript functions for handling user interactions.

calculate.php

Handles the form submission and determines which mathematical operation to perform based on the user input. It includes the appropriate PHP file for the operation and returns the result.

addition.php

Performs the addition operation. It takes the user input, splits it into numbers, and calculates the sum.

subtraction.php

Performs the subtraction operation. It takes the user input, splits it into numbers, and calculates the difference.

multiplication.php

Performs the multiplication operation. It takes the user input, splits it into numbers, and calculates the product. division.php Performs the division operation. It takes the user input, splits it into numbers, and calculates the quotient.

exponentiation.php

Performs the exponentiation operation. It takes the user input, splits it into the base and exponent, and calculates the power.

sqrt.php

Performs the square root operation. It takes the user input, extracts the number, and calculates the square root.

logarithm.php

Performs the logarithm operation. It takes the user input, extracts the number, and calculates the base-10 logarithm.

percentage.php

Performs the percentage operation. It takes the user input, splits it into numbers, and calculates the percentage.

styles.css

Contains the CSS styles for the calculator interface. It ensures a responsive and user-friendly design.

scripts.js

Contains the JavaScript functions for handling user interactions and updating the display in real-time.

Troubleshooting

If the calculator is not working as expected, check the following:

1. PHP Errors:

· Ensure PHP is correctly installed and configured. · Check the PHP error log for any errors.

2.JavaScript Errors:

· Open the browser's developer tools and check the console for any JavaScript errors.

3. Network Issues:

· Ensure the web server is running and accessible.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

Acknowledgements

· Thanks to the developers of PHP, JavaScript, HTML, and CSS for providing the tools to build this project. · Special thanks to the open-source community for their valuable resources and support.

About

This PHP Calculator is a simple yet powerful tool for performing basic arithmetic operations. Built using PHP, it offers a user-friendly interface and efficient calculation capabilities. Whether you need to add, subtract, multiply, or divide, this calculator provides a reliable solution for your mathematical needs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published