Conditional Statements – Example
local coordx, coordy
io.write("Input the X value for the coordinate:")
coordx = tonumber(io.read())
io.write("Input the Y value for the coordinate:")
coordy = tonumber(io.read())
if (coordx > 0) and (coordy > 0) then
io.write("The coordinate point lies in the First quandrant.\n")
elseif (coordx < 0) and (coordy > 0) then
io.write("The coordinate point lies in the Second quandrant.\n")
elseif (coordx < 0) and (coordy < 0) then
io.write("The coordinate point lies in the Third quandrant.\n")
elseif (coordx > 0) and (coordy < 0) then
io.write("The coordinate point lies in the Fourth quandrant.\n")
elseif (coordx == 0) and (coordy == 0) then
io.write("The coordinate point lies at the origin.\n")
end