Assignment #2 - 91B

Assignment #2 - 91B


Assignment #2

Due: Thursday September 26, 1991

Weight: 20


This assignment requires you to calculate certain features of
two-dimensional geometrical figures.

For the purposes of this assignment, a triangle will be specified as
three vertex points (x1, y1), (x2, y2), (x3, y3).  These are to be read
in as pairs of real numbers, with one point (2 real numbers) per line of
input data.

For each set of three points read in, you are firstly to calculate
whether the points constitute a valid triangle (i.e. are DISTINCT and
do NOT lie on a single line).  Print out a message for invalid data and
proceed to the next data set.

For valid input data, print out both the area and the perimeter of the
resulting triangle.

The end of data will be flagged by three "zero" points --- (0, 0), (0,
0), (0, 0).

Sample data:

/DATA
 2.5 4.5
 3.6 7.1
-1.2 2.43
 2.0 3.0  Checking for distinct points
 2.0 3.0
 4.0 5.0
 2.0 3.0  Checking for Co-linear case
 2.0 4.0
 2.0 5.0
 0.0 0.0  End of file indication
 0.0 0.0
 0.0 0.0