Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.wrap("right")
- function newLine()
- x,y = monitor.getCursorPos()
- monitor.setCursorPos(1,y+1)
- end
- function add(x, y)
- monitor.write(x+y)
- newLine()
- end
- function subtract(x, y)
- monitor.write(x-y)
- newLine()
- end
- function multiply(x, y)
- monitor.write(x*y)
- newLine()
- end
- function divide(x, y)
- monitor.write(x/y)
- newLine()
- end
- while(true) do
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.setTextColor(1024)
- io.write("Enter first number")
- x = io.read(
- io.write("Enter second number")
- y = io.read
- io.write("Enter operation")
- op = io.read
- if op == "add" then
- add(x,y)
- end
- if op == "subtract" then
- subtract(x,y)
- end
- if op == "multiply" then
- multiply(x,y)
- end
- if op == "divide" then
- divide(x,y)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement