PROGRAM Triangle (Input,Output);
(* Read 3 sides.  Determine what kind of triangle, if any *)

TYPE
   Triangles = (Isoceles,Equilateral,Scalene);

VAR
   S1, S2, S3 : Integer;
   Kind : Triangles;


(*********************************************************)
FUNCTION PrintTriangle (Kind : Triangles) : String;
Begin
   CASE Kind OF
     Isoceles    : PrintTriangle := 'Isoceles';
     Equilateral : PrintTriangle := 'Equilateral';
     Scalene     : PrintTriangle := 'Scalene';
   END;
End;


(**********************************************************)
FUNCTION ValidTriangle (S1, S2, S3 : Integer) : Boolean;
(* 3 sides make a triangle if every 2 sides is greater than third side *)
Begin
   IF (S1 + S2 > S3) AND
      (S1 + S3 > S2) AND
      (S2 + S3 > S1) THEN
        ValidTriangle := True
   ELSE
      ValidTriangle := False;
End;



(*********************************************************)
FUNCTION TriType (S1, S2, S3 : Integer) : Triangles;
Begin
  IF (S1=S2) AND (S2=S3) THEN
     TriType := Equilateral
  ELSE IF (S1=S2) OR (S2=S3) OR (S1=S3) THEN
          TriType := Isoceles
       ELSE
          TriType := Scalene;
End;



BEGIN
   WHILE NOT EOF DO
    Begin
      Writeln;
      Write('Enter 3 sides of a triangle: ');
      Readln(S1,S2,S3);
      IF ValidTriangle(S1,S2,S3) THEN
        Begin
          Kind := TriType(S1,S2,S3);
          Writeln('This is a ',PrintTriangle(Kind),' triangle.');
        End
      ELSE
         Writeln('Not a triangle');
    End;
END.

