Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local operation = {
- ["+"] = function(x,y) return x+y end,
- ["-"] = function(x,y) return x-y end,
- ["*"] = function(x,y) return x*y end,
- ["/"] = function(x,y) return x/y end
- }
- local function default()
- print("No opreation has been selected")
- end
- print("Choose your first number:")
- local num1 = io.read()
- print("Choose your second number:")
- local num2 = io.read()
- print("Choose your operation:")
- local func = operation[io.read()] or default
- print(func(num1,num2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement