Unformatted Attachment Preview
Engr 123
Assignment 05
Assigned: February 17, 2016
Due: March 2, 2016
Given below is a set of 8 points which represent x, y coordinates in a plane and are
declared as a two-dimensional array of doubles:
private double[,] pts = { {0, 0},
{2, 3},
{-4, 6},
{-8, -1},
{6, -3},
{8, 5},
{-1, 9},
{-9, -3}
};
Write a C# GUI application which will find the largest triangle made from any three
points, the smallest triangle, the two points furthest apart, the two points closest together,
the point closest to the origin, and the point furthest from the origin. The points should
be displayed in a list box with each point assigned a number from 1 to 8. The program
user should be given six options to select from: A) Largest triangle, B) Smallest triangle,
C) Points furthest apart, D) Points closest together, E) Point furthest from the origin, and
F) Point closest to the origin. When the user chooses one of these options your program
should print the result on a line in a list box labeled results.
A GUI has been created for you that you may use for this program. It is given as
Asn05GUI.zip on the web site. Download this program as a starting point, unzip it, and
rename the project folder Asn05XXX where XXX are your three initials. Write the code
for the events to produce the desired results. A sample program output is on the next
page.
A triangle can be formed by connecting any three of the points. Write a C#
program to search through all possible combinations of three points to
determine which three form a triangle with the largest area.
To compute the area of a triangle use the formula:
Area = s(s − a )(s − b)(s − c)
where s = (a + b + c) / 2 and a, b, and c are the three sides of the triangle.
To calculate the length of the sides you can use the distance formula:
Distance = ( x1 − x2 ) 2 + ( y1 − y2 ) 2
where x1 , y1 are the coordinates of one point and x 2 , y 2 is the coordinates of the second
point.
Figure 1
Sample output when "Find largest triangle" is checked.
After you get your program running correctly, place a copy of the design into the project
folder as a doc or docx file. Right click on the project folder and choose Send To →
Compressed zip file. Rename the compressed zip file as Asn05XXX.zip where XXX are
you three initials. Upload the renamed file to \\cecsfp01\users\everyone\engr123.