You will have the following functions (no violation of these interfaces) and you may have others, as needed:
− public static void GenerateRandomTriangles(int numTriangles)
to create a file RandomTriangles.dat having the following format (including some comments like the ones
shown below) with random integer coordinates (x, y) of the three vertices of a triangle. Each x and y will be a
random integer in the range 0 <= x, y < 150. (Use seed for random numbers.)
5 //numTriangles; each line below gives integer coordinates (x, y) of vertices of a triangle
( 20, 100) ( 25, 88) (112, 99)
... ... ...
− public String TriangleType(Point a, Point b, Point c),
to return one of the values "equilateral", "isosceles", and "scalar".
− private void TestTriangles()
to test the two functions above. This function should output the points, the length of the edges (upto 3 decimal
points), and the triangle type. It should allow the user a choice to continue processing the triangles or to quit
(give a short, clear prompt).
− public static void main(String args)
to call the other functions for the most part.
Point will be a subclass of the main class (which you might call TestTriangleType). It will have two integer
fields/attributes, with a constructor Point(int x, int y) and another member-function public void
Print() to print the coordinates of a point.
7 Months Ago
Related Article:Help printing a triangle using loops.
is a solved Java discussion thread by paulsoncall that has 5 replies, was last updated 1 year ago and has been tagged with the keywords: loops, triangle.
There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you.