У меня есть переменная exp
где хранится значение типа string
, как я могу изменить на математическое выражение?
fun main() {
while (true){
println("Enter the first operand")
val x = readLine()
println("Enter operation")
val operator = readLine()!![0]
println("Enter the second operand")
val y = readLine()
println("Enter the second operation")
val operator1 = readLine()!![0]
println("Enter the Third operand")
val z = readLine()
println("Enter the third operation")
val operator2 = readLine()!![0]
println("Enter the Fourth operand")
val q = readLine()
println("Now to see the result enter =")
val res = readLine()
val exp = x+operator+y+operator1+z+operator2+q
if (res == "=") {
println(exp)
} else {
println("Something goes wrong")
}
}
}