Calculator with four functions

Report a typo

In the template below you have simple calculator functions that can subtract, add, divide, and multiply two numbers. Now, we've decided to upgrade it to perform more complex tasks, such as logarithmic functions. For that, separate functions are a better solution. Let's start by decomposing what we have.

Take a look at the template and decompose calculator operations into four functions: subtractTwoNumbers(a: Long, b: Long) for subtraction, sumTwoNumbers(a: Long, b: Long) for addition, divideTwoNumbers(a: Long, b: Long) for integer division and multiplyTwoNumbers(a: Long, b: Long) for multiplication. Each function should print the calculation result.

Note that you can't divide by zero. In case your second argument is zero in the corresponding function, print the message "Division by 0!".

You don't need to implement the main function. Just complete the function templates provided to you.

Sample Input 1:

1 + 2

Sample Output 1:

3

Sample Input 2:

4 / 0

Sample Output 2:

Division by 0!
Write a program in Kotlin
// Implement your functions here
fun subtractTwoNumbers...


fun sumTwoNumbers...


fun divideTwoNumbers...


fun multiplyTwoNumbers...
___

Create a free account to access the full topic