Project 76: Perimeter of Polygon

A famer has a piece of land as shown in the picture below.  The coordinates of the endpoints are (1, 2), (5, 1), (5,3), (3, 3) and (1,5).  The farmer wants to buy fencing to put around the piece of land.  How much total fencing should he buy (all units are in miles)?


As shown below, he will need 13.95 miles of fencing to enclose the piece of land.

Project 76: Variables 'x' and 'y' have been initialized.  There is also a working method called distance.

x is an array that represents the x-coordinates for points of a polygon (x will have at least 3 values)

y is an array that represents the y-coordinate for points of a polygon (y will have at least 3 values)

distance(x1,y1,x2,y2) returns the distance between the points (x1, y1) and (x2, y2)

Task:  Appropriately initialize the value of 'perimeter' that represents the perimeter of the polygon.

**If your code works for 5 test cases, you can enter your e-mail address

Universal Computational Math Methods:

pow(5,2) returns 25.0

abs(-3.0) returns 3

sqrt(49.0) returns 7.0