Question: Computing the Area of a Triangle Given Its Corner Points: Use the template code Lab 9 Template.java for this exercise. Its main method creates a

Computing the Area of a Triangle Given Its Corner Points:
Use the template code Lab9Template.java for this exercise. Its main method
creates a 2-D array with 3 rows and 2 columns,
reads the corner point coordinates of a triangle (A(x1
, y1
), B(x2
, y2
) and C(x3
, y3
)) from
the user into the 2-D array then prints these corner point coordinates,
computes then prints the side lengths of the triangle (a, b and c) from its corner points,
and computes then prints the area of the triangle using the Heron's formula.
Note: The last two methods described below are used in the main method.
Write a method that
has the header public static double distance(double[] point1, double[] point2)
and computes then returns the Euclidean distance between the two points whose
coordinates are given as two arrays (point1={x1, y1} and point2={x2, y2}).
Write a second method that
has the header public static double[] computeSideLengths(double[][] cornerPoints),
computes the side lengths of a triangle by using the distance method explained above,
stores the result in an array and returns the array.
The corner points of the triangle are given to the method as a 2-D array (cornerPoints).
Write a third method that
has the header public static double computeArea(double[] sideLengths)
and uses the Herons formula (given on the right) to compute then return the area of the
triangle whose side lengths are given as an array (sideLengths).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!