Skip to content

Instantly share code, notes, and snippets.

@michaelkotor
Last active August 26, 2025 08:36
Show Gist options
  • Select an option

  • Save michaelkotor/ed99907d23ad708e2115798c61e9a9d7 to your computer and use it in GitHub Desktop.

Select an option

Save michaelkotor/ed99907d23ad708e2115798c61e9a9d7 to your computer and use it in GitHub Desktop.
You are given a story from Product Owner. He wants to integrate a calculator to the banking app. You may ask clarification quiestions in needed.
You need to write a prodcution-ready function public int calculate(int a, int b, char operator).
This method should return the result of applying the operator to the two numbers.
Supported operators are '+' for addition, '-' for subtraction, '*' for multiplication, and '/' for division.
For example: calculate(4, 2, '+') should return 6, calculate(10, 3, '-') should return 7, calculate(3, 5, '*') should return 15, and calculate(8, 2, '/') should return 4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment