A=input('give the coordinates of A as a row array "[x1,y1]:"');
B=input('give the coordinates of B as a row array "[x2,y2]:"');
C=input('give the coordinates of C as a row array "[x3,y3]:"');

x1=A(1);x2=B(1);x3=C(1);
y1=A(2);y2=B(2);y3=C(2);

%if A,B,C are collinear then x1(y2-y3)+x2(y3-y1)+x3(y1-y2)=0

test=x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2);

 c=sqrt((A(1)-B(1))^2+(A(2)-B(2))^2);
 b=sqrt((A(1)-C(1))^2+(A(2)-C(2))^2);
 a=sqrt((B(1)-C(1))^2+(B(2)-C(2))^2);
    
if test==0
    disp('')
    disp('A,B and C are collinear')
    disp('')
    disp(['The distance between A and B is ', num2str(c)])
    disp(['The distance between A and C is ', num2str(b)])
    disp(['The distance between B and C is ', num2str(a)])

else
    disp('')
    disp('A,B and C are not collinear')
    S=(a+b+c)/2;
    TrArea=sqrt(S*(S-a)*(S-b)*(S-c));
    disp('')
    disp(['The distance between A and B is ', num2str(c)])
    disp(['The distance between A and C is ', num2str(b)])
    disp(['The distance between B and C is ', num2str(a)])
    disp(['the area of the ABC triangle is ', num2str(TrArea)])

end

