Guest User

calculator

a guest
Jul 17th, 2015
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. loop = true
  2. while loop == true do
  3. textutils.slowPrint("Welcome to EnderCalc Version 0.1!")
  4. print("Type End to cancel the program")
  5. print("Would you like to add, subtract, multiply, or divide?")
  6. local operation = read()
  7. if operation == "end" or "End" or "e" or "E" or "END" then
  8.  loop = false
  9. end
  10. --------------------------------------------------
  11. function nums()
  12. print("Enter the first number to be operated on please: ")
  13. local num1 = tonumber(read())
  14. print("Enter the second number to be operated on please")
  15. local num2 = tonumber(read())
  16. end
  17. --------------------------------------------------
  18. if operation == "add" or "ADD" or "a" or "A" then
  19.   nums()
  20.   local result = num1 + num2
  21.   print(result)
  22. elseif operation == "subtract" or "Subtract" or "s" or "S" then
  23.   nums()
  24.   result = num1 - num2
  25.   print(result)
  26. elseif operation == "multiply" or "Multiply" or "m" or "M" then
  27.   nums()
  28.   result = num1 * num2
  29.   print(result)
  30. elseif operation == "divide" or "Divide" or "d" or "D" then
  31.   nums()
  32.   result = num1 / num2
  33.   print(result)
  34. else
  35.   print("Try again")
  36. end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment