Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

Students also viewed these Databases questions

Question

Define conformity. (p. 350)

Answered: 1 week ago