
% Lab 3 Solutions
% CS 1109, Summer 2011
% July 5

% This script prompts the user to enter an x and y coordinate. It then
% prints out the quadrant of the Cartesian plane in which (x,y) lies. If
% (x,y) is on an axis, or is the origin, then an appropriate message is
% printed

x = input('Please enter the x coordinate: ');
y = input('Please enter the y coordinate: ');

% Determine the quadrant in which (x,y) lies
if ((x > 0) & (y > 0))
    fprintf('Point lies in quadrant 1\n');
elseif ((x < 0) & (y > 0))
    fprintf('Point lies in quadrant 2\n');
elseif ((x < 0) & (y < 0))
    fprintf('Point lies in quadrant 3\n');
elseif ((x > 0) & (y < 0))
    fprintf('Point lies in quadrant 4\n');
elseif ((x == 0) & (y == 0))
    fprintf('Point is the origin\n');
elseif (x == 0)
    fprintf('Point lies on y axis\n');
else
    fprintf('Point lies on x axis\n');
end
