Calculator

Report a typo

The aliens decided to send humans a basic calculator and chose Scala as the source language. The calculator should only add or subtract two natural numbers in the form of first operation second. The program should output the result of the calculation. If the format of the input doesn't match the defined format of the program, the Unsupported expression should be printed. During transmission, the alien program was corrupted. Try to recover the missing parts.

Sample Input 1:

1 + 3

Sample Output 1:

4
Write a program in Scala 3
@main def calculator = {
val input = scala.io.StdIn.readLine().split(' ').toList
input match
case a :: "+" :: b :: Nil if a.forall(_.isDigit) && ??? =>
println(a.toInt + ???)
case a :: ??? :: b :: Nil ??? =>
println(???)
case ??? => println("Unsupported expression")
}
___

Create a free account to access the full topic