Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function calculator()
- while true do
- print("What is the operation you want to act upon?")
- op = read()
- if op == "add" or "subtract" or "multiply" or "divide" then
- print("What is the first number acted upon?")
- num1 = tonumber(read())
- print("and the second number?")
- num2 = tonumber(read())
- if op == "add" then
- result = num1 + num2
- print(result)
- elseif op == "subtract" then
- result = num1 - num2
- print(result)
- elseif op == "multiply" then
- result = num1 * num2
- print(result)
- elseif op == "divide" then
- result = num1 / num2
- end
- elseif op == "exit" then
- print("Are you sure you want to exit the calculator application?")
- confirm = read()
- if confirm == "yes" then
- break
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement