Skip to content

Repository files navigation

Spring Simple Calc

Overview

This project is a simple web-based calculator built using Java and Spring Boot. It provides a REST API that allows users to perform basic arithmetic operations such as addition, subtraction, multiplication, and division.

The application is designed as a lightweight backend service for learning and practicing Spring Boot fundamentals, including REST controllers, request handling, and basic service structure.

Endpoints

1. Adding numbers

Endpoint: /api/calc/add

curl -X POST "http://localhost:8080/api/calc/add" \
  -H "Content-Type: application/json" \
  -d '{"values":[1,2,3,4]}'

Response (200):

{
  "result": 10.0
}

2. Subtracting numbers

Endpoint: /api/calc/subtract

curl -X POST "http://localhost:8080/api/calc/subtract" \
  -H "Content-Type: application/json" \
  -d '{"values":[20,5]}'

Response (200):

{
  "result": 15
}

3. Division of numbers

Endpoint: /api/calc/divide

curl -X POST "http://localhost:8080/api/calc/divide" \
  -H "Content-Type: application/json" \
  -d '{"values":[50,2]}'

Response (200):

{
  "result": 25
}

4. Multiplication of numbers

Endpoint: /api/calc/multiply

curl -X POST "http://localhost:8080/api/calc/multiply" \
  -H "Content-Type: application/json" \
  -d '{"values":[50,2,0]}'

Response (200):

{
  "result": 0
}

Errors

1. When the values are not defined:

[
  {
    "message": "At least one value is required."
  }
]

2. When at least one number in the division is equal to zero:

[
  {
    "message": "Values must not contain zero."
  }
]

Technologies used in this project

  • Java
  • Spring Boot
    • Spring Boot DevTools
    • Spring Web
    • Validation

About

Lightweight calculator API built with Java Spring Boot. Provides endpoints for basic arithmetic operations.

Resources

Stars

Watchers

Forks

Contributors

Languages