Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

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