Skip to content

Instantly share code, notes, and snippets.

View michaelkotor's full-sized avatar

Michael michaelkotor

  • EPAM Systems
  • Vilnius, LT
View GitHub Profile
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.
@Service
public class UserSrvc {
public UserRepository mySrvc;
public UserSrvc() {
this.mySrvc = new UserRepository();
}
public User doSmthngImportant(Long id) {
if (id == null) {