% hw007.m
% John Burkardt
% Get x, y, z from the user.
% Report whether x, y and z can be the sides of a triangle.
%
x = input ( 'Enter value x: ' )
y = input ( 'Enter value y: ' )
z = input ( 'Enter value z: ' )
%
%  One way to do it:
%
triangular = ( ...
  ( z <= x + y ) && ...
  ( y <= x + z ) && ...
  ( x <= y + z ) );
if ( triangular )
  fprintf ( '  Numbers can form a triangle.\n' );
else
  fprintf ( '  Numbers cannot form a triangle.\n' );
end
%
%  Another way.
%
triangular = true;
if ( x + y < z )
  triangular = false;
end
if ( x + z < y )
  triangular = false;
end
if ( y + z < x )
  triangular = false;
end
if ( triangular )
  fprintf ( '  Numbers can form a triangle.\n' );
else
  fprintf ( '  Numbers cannot form a triangle.\n' );
end

