A simple calculator

Report a typo

Write a simple calculator that reads three values from the line: the first number, the operator and the second number.

The program should apply the operation to the numbers and output the result. Note that the numbers are long.

The calculator must support:

  • addition: +
  • subtraction: -
  • integer division: /
  • multiplication: *

If a user performs the division and the second number is 0, output Division by 0!

If the input operator is not in the list, output Unknown operator.

Sample Input 1:

10000000000 + 20000000000

Sample Output 1:

30000000000

Sample Input 2:

3000 / 0

Sample Output 2:

Division by 0!

Sample Input 3:

10000 ! 300

Sample Output 3:

Unknown operator
Write a program in Kotlin
fun main() {
// write your code here
}
___

Create a free account to access the full topic