This project is a simple API developed using Spring Boot 3.2.7, designed to perform basic arithmetic operations such as addition, subtraction, multiplication, division, mean calculation, and square root. It serves as an example of how to create and manage APIs in Spring Boot, showcasing exception handling and custom error responses.
The API provides the following endpoints for arithmetic operations:
- Addition:
/sum/{numberOne}/{numberTwo}
- Subtraction:
/subtraction/{numberOne}/{numberTwo}
- Multiplication:
/multiplication/{numberOne}/{numberTwo}
- Division:
/division/{numberOne}/{numberTwo}
- Mean:
/mean/{numberOne}/{numberTwo}
- Square Root:
/squareRoot/{number}
Each endpoint accepts two numbers as path variables, except for the square root, which only requires one number. The API is designed to handle invalid inputs and division by zero scenarios gracefully, returning meaningful error messages in JSON format.
- JDK 17 or later
- Maven 3.2+
- Clone the repository to your local machine.
git clone https://github.com/DanielF-Cardoso/spring-boot-calculator.git
- Run the following command to build the project:
mvn clean install
- Once the build is successful, start the application with:
mvn spring-boot:run
The application will start running on http://localhost:8080.
You can access the API endpoints using any HTTP client such as Postman
http://localhost:8080/sum/1/2
Replace /sum/1/2 with the desired endpoint and input values accordingly.