Advertisement
Guest User

[LUA] calculator

a guest
Dec 15th, 2019
971
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. --[[
  2. Credits to lil fr#7486
  3. : )
  4. ]]
  5.  
  6. print("Hello what is your name?")
  7. name = io.read()
  8. print("Would you like to start the calculator "..name.."?".. " Yes/No")
  9. startcalc = io.read()
  10.  
  11.  
  12. if startcalc == "No" then
  13.   print("Goodbye then ".."")
  14.     os.exit()
  15.   end
  16. if startcalc == "Yes" then
  17.   repeat
  18.   print("Enter first number: ")
  19.   num1 = io.read()
  20.  
  21.   print("Enter second number: ")
  22.   num2 = io.read()
  23.  
  24.   print("What would you like to do to these numbers?... Divide, Multiply, Add, Subtract")
  25.   op = io.read()
  26.  
  27. if op == "Divide" then
  28.   print(num1 / num2)
  29. end
  30. if op == "Multiply" then
  31.   print(num1 * num2)
  32. end
  33. if op == "Add" then
  34.   print(num1 + num2)
  35. end
  36. if op == "Subtract" then
  37.   print(num1 - num2)
  38. end
  39.   print("Would you like to do some more math? Yes/No")
  40.   restart = io.read()
  41.  
  42.   if restart == "Yes" then
  43.  
  44.    
  45.     if restart == "No" then
  46.       print("Bye "..name)
  47.     end
  48.   end
  49. until restart == "No"
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement