Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1,1)
- print"The Calculator Will Produce An Error If You Input A Letter Or Any Character Apart From A Number And A Dot"
- sleep(2)
- sin = 0
- function menu(text, id)
- if sin == id then
- write("[ "..text.." ]")
- else
- write(" "..text.." ")
- end
- print""
- end
- term.clear()
- term.setCursorPos(1,1)
- print"Enter First Number"
- write""
- input = tonumber(read())
- term.clear()
- term.setCursorPos(1,1)
- print"Select A Symbol"
- while true do
- term.setCursorPos(1,4)
- menu("+ ", 0)
- menu("- ", 1)
- menu("/ ", 2)
- menu("* ", 3)
- menu("^ ", 4)
- menu("/^", 5)
- local event, key = os.pullEvent("key")
- if key == 208 then
- if sin > 4 then
- sin = sin - 5
- else
- sin = sin + 1
- end
- elseif key == 200 then
- if sin < 1 then
- sin = sin + 5
- else
- sin = sin - 1
- end
- elseif key == 28 then
- if sin == 0 then
- term.clear()
- term.setCursorPos(1,1)
- print"Enter Second Number"
- write""
- input2 = tonumber(read())
- output = input2 + input
- term.clear()
- term.setCursorPos(1,1)
- print(output.." Press Enter To Continue")
- while true do
- event, key = os.pullEvent("key")
- if key == 28 then
- term.clear()
- term.setCursorPos(1,1)
- return
- end
- end
- end
- if sin == 1 then
- term.clear()
- term.setCursorPos(1,1)
- print"Enter Second Number"
- write""
- input2 = tonumber(read())
- output = input - input2
- term.clear()
- term.setCursorPos(1,1)
- print(output.." Press Enter To Continue")
- while true do
- event, key = os.pullEvent("key")
- if key == 28 then
- term.clear()
- term.setCursorPos(1,1)
- return
- end
- end
- end
- if sin == 2 then
- term.clear()
- term.setCursorPos(1,1)
- print"Enter Second Number"
- write""
- input2 = tonumber(read())
- output = input / input2
- term.clear()
- term.setCursorPos(1,1)
- print(output.." Press Enter To Continue")
- while true do
- event, key = os.pullEvent("key")
- if key == 28 then
- term.clear()
- term.setCursorPos(1,1)
- return
- end
- end
- end
- if sin == 3 then
- term.clear()
- term.setCursorPos(1,1)
- print"Enter Second Number"
- write""
- input2 = tonumber(read())
- output = input2 * input
- term.clear()
- term.setCursorPos(1,1)
- print(output.." Press Enter To Continue")
- while true do
- event, key = os.pullEvent("key")
- if key == 28 then
- term.clear()
- term.setCursorPos(1,1)
- return
- end
- end
- end
- if sin == 4 then
- term.clear()
- term.setCursorPos(1,1)
- print("Enter Second Number")
- write""
- input2 = tonumber(read())
- output = input^input2
- term.clear()
- term.setCursorPos(1,1)
- print(output.." Press Enter To Continue")
- while true do
- event, key = os.pullEvent("key")
- if key == 28 then
- term.clear()
- term.setCursorPos(1,1)
- return
- end
- end
- end
- if sin == 5 then
- term.clear()
- term.setCursorPos(1,1)
- print("Enter Second Number")
- input2 = tonumber(read())
- output = input^(1/input2)
- term.clear()
- term.setCursorPos(1,1)
- print(output.." Press Enter To Continue")
- while true do
- event, key = os.pullEvent("key")
- if key == 28 then
- term.clear()
- term.setCursorPos(1,1)
- return
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment