Calculator Tutorial
is what that string does
add = "add" ------ it says when i tell it to add then it codes it to the word add
subtract = "subtract" ------ the same as for add just with subtract
multiply = "multiply" ------ same as for add just with multiply
devide = "devide" ------ sameas for add just for devide
print ("Do you want to add, subtract, multiply or devide?") ------- prints the message written between (" and ")
write ("") ------- makes room for you to write if you want add, subtract, multiply or devide.
put = io.read() ------ reads what you write and codes it in to the word "put"
write ("Enter your first number: ") ------ makes room for you to write your first number.
input = io.read() ------ reads what you write above and codes it in to the word "input"
write ("Enter your second number: ") -------- makes room for you to write the second number.
output = io.read() ------- reads what you write above and codes it into the word "output"
if put == add ------ then checks if the word you wrote when you chose if you wanted to add, subtract, multiply or devide then it checks if its the same as add, if its not thn it does nothing
x = input + output ------- if the word you wrote was the same as add then this adds the first number (input) and the second number (output) and then codes it into the letter x
print ("That = ", x) ------- prints That = (and then what x is)
elseif put == subtract then ------- if its not add that you wrote then this checks if its subtract
x = input - output -------- if it was subtract then this subtracts the input from the output and codes it into the letter x
print ("That = ", x) ------- the same as for add
elseif put == multiply then ------- if its not add or subtract you wrote then it checks if its multiply
x = input * output ------- if it is it multiplies input and output and codes it into the letter x
print ("That = ", x)------ the same as for add
elseif put == devide then -------- if its not add, subtract or multiply you wrote then this checks if its devide
x = input / output ------- this devides input from output and codes them into the letter x
print ("That = ", x) ------- the same as for add
end ------ since we only got if then we only need 1 end
sleep(3) ------- waits 3 seconds before executing the next string
term.clear() ------- clears the screen
term.setCursorPos(1, 1) ------- returns the cursor to the top of the screen