I have this
val str = "9617 / 20634"
9617 & 20634
It is easier to remove spaces after the split than before. Unless you are expected to trim it before, here is a simpler way of doing it.
val Array(x, y) = "9617 / 20634".split("/").map(_.trim.toFloat) val p = x / y * 100
Values are converted to
Float to prevent integer division leading to 0.
val Array(x,y) = ... statement is just another way of calling
unapplySeq of the Array object.