#### Free University of Bolzano/Bozen

Faculty of Computer Science - Bachelor in Applied Computer Science

Bachelor in Production Engineering

Introduction to Programming - A.A. 2004/2005

## Exercise

Class `Triangle`

Design and realize a Java class `Triangle`

to represent triangles.
The following functionalities are of interest for triangles:
- creation of a triangle, given the lenghts of the three sides;
- return of the length of the longest side, the intermediate side, and the
shortest side;
- return of the perimeter of the triangle;
- return of the area of the triangle;
- return of a string representing the type of the triangle, which may be
either regular, symmetric, or irregular.
- test whether the three sides can actually be the sides of a triangle;
i.e., they respect the triangular inequality, which states that the
longest side is shorter than the sum of the other two;

Notice that, given the lengths *a*, *b*, and *c* of the
three sides of a triangle, the area *A* can be computed according to
*A = sqrt(s*(s-a)*(s-b)*(s-c)}*, where *s = (a+b+c)/2* is the
semiperimeter.