use java the Checking the Types of Triangle
Requirements
Given a set of (x, y) coordinates representing the vertices of triangles, write a Java program to check the types of all the triangles formed by selecting any three given vertices. The following shows an example displaying all possible triangles formed from 6 vertices.
1. Write appropriate methods to do the following tasks, one method for each:
- Given the coordinates of the two vertices of a side of a triangle, calculate its length.
- Given the length of the three sides of a triangle, calculate its area.
- Given the length of the three sides of a triangle, check if it is a valid triangle.
- Given the length of the three sides of a triangle, check if it is right-angled.
- Given the length of the three sides of a triangle, check if it is isosceles.
- Given the length of the three sides of a triangle, check if it is scalene.
2. Input the coordinates of the vertices of triangles from a text file. Each row represents the (x, y) coordinates of a vertex of a triangle, and the two coordinate integers should be read into two integer array representing the x and y coordinates of all vertices. The last row (999, 999) is used to indicate end-of-file and should not be used as formal data.
An example input text file is shown below:
vertices.txt
-5 2
0 2
8 2
8 -11
4 2
4 5
999 999
3. Using appropriate iterations to select all the triangles formed by choosing any three vertices inputted in (1).
- For each triangle, check and display its types.
- Find and display the triangle with maximum area and the one with minimum area. The format of the maximum and minimum area is having 2 decimal places only.
the format of the output of the program is shown below
point1 point2 point 3 Types of Triangle
(-5,2) (0,2) (8,2) Non-triangle
(-5,2) (0,2) (8,-11) Scalene