% This file demonstrates piece-wise function evaluation using
% a nested if-blocks

x = input('input x: ');
y = input('input y: ');

if (x >= 0)
    if(y >= 0)
        fx = x + y;
    else 
        fx = x + y*y;
    end
else
    if(y >= 0)
        fx = x*x + y;
    else
        fx = x*x + y*y;
    end
end

fprintf('Result: %f\n',fx);
       