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 quadrant.\n")
elseif (coordx < 0) and (coordy > 0) then
io.write("The coordinate point lies in the Second quadrant.\n")
elseif (coordx < 0) and (coordy < 0) then
io.write("The coordinate point lies in the Third quadrant.\n")
elseif (coordx > 0) and (coordy < 0) then
io.write("The coordinate point lies in the Fourth quadrant.\n")
elseif (coordx == 0) and (coordy == 0) then
io.write("The coordinate point lies at the origin.\n")
end