Practice Problem #2
Survey Closure

A survey of a piece of land consists of a series of directions and distances, starting at one corner and going clockwise or counterclockwise around the perimeter of the land until the starting point is reached again. The file SURVEY1.TXT contains a sequence of such survey measurements where each edge is described with three numbers: the first two numbers are the direction of sighting to the next corner measured in degrees and minutes, the third number is the distance to the next corner in feet. Below is the complete contents of SURVEY1.TXT to illustrate: the first edge is in the direction 338 degrees 39 minutes for a distance of 200 feet ... the last edge is in the direction 86 degrees 44 minutes for 36 feet.

338 39 200
50 44 198
180 0 52
103 33 106
192 55 305
295 12 51
44 57 59
303 45 23
230 0 134
338 39 76
86 44 36

Angles are measured using all 360 degrees, starting with due North being 0 degrees. Thus, East is at 90 degrees, South at 180 degrees, and West at 270 degrees.

Unfortunately, some surveys are not as accurate as others. Inaccurate surveys are said "not to close" because when the directions and distances are followed precisely, the last edge does not return to the starting point. For purposes of determining closure, if the last edge leads to a point that is less than or equal to one foot from the starting point, the survey does close (is accurate enough); but for any greater distance between the starting and ending points, the survey does not close.

You are to write a program that can evaluate the survey in whatever file is specified and to determine if the survey closes. Your program should display the distance between ending point and the starting point and display an appropriate message regarding whether or not the survey closes. For SURVEY1.TXT, the result should be

Start-end distance: 2.64704
The survey does not close.