8. Area of Triangle You are given 3 sets of coordinates that form a triangle. Write...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
8. Area of Triangle You are given 3 sets of coordinates that form a triangle. Write code to find the area of the triangle enclosed by those coordinates. For example, the 3 points have coordinates given as x = [0, 3, 6] and y = [0, 3, 0], aligned by index, so the 3 coordinates are [0,0], [3,3], [6,0]. The height of the triangle is 3, and the width is 6, so the area of the triangle is 6 * 3/2 = 9. All resulting areas will be whole numbers. Not all triangles will contain a right angle. H q Constraints • 1 ≤ x[i] < 100000 • 1 ≤ y[i] < 100000 16 4+ 3+ ល H 7 -2+ H IN To getTriangleArea has the following parameter(s): x: An integer array, that denotes the x coordinates. y: An integer array, that denotes the y coordinates. + ho 10 Function Description Complete the function getTriangleArea in the editor below. The function must return an integer which indicates the area of the triangle. 8 ▾ Sample Case 0 Sample Input 0 3 oWowашоw 0 3 6 3 0 3 Sample Output 0 9 Explanation 0 Here, x = [0, 3, 6] and y = [0, 3, 0] would mean that the 3 coordinates are [0,0], [3,3], [6,0]. Thus, the area would be 9. 12 13 14 15 * 1. INTEGER_ARRAY X 16 * 2. INTEGER ARRAY Y */ 17 18 19 20 21 * * The function is expected to return an INTEGER. * The function accepts following parameters: int getTriangleArea (vector x, vector y) { 22 23 } return area; 24 25 int main() ... 8. Area of Triangle You are given 3 sets of coordinates that form a triangle. Write code to find the area of the triangle enclosed by those coordinates. For example, the 3 points have coordinates given as x = [0, 3, 6] and y = [0, 3, 0], aligned by index, so the 3 coordinates are [0,0], [3,3], [6,0]. The height of the triangle is 3, and the width is 6, so the area of the triangle is 6 * 3/2 = 9. All resulting areas will be whole numbers. Not all triangles will contain a right angle. H q Constraints • 1 ≤ x[i] < 100000 • 1 ≤ y[i] < 100000 16 4+ 3+ ល H 7 -2+ H IN To getTriangleArea has the following parameter(s): x: An integer array, that denotes the x coordinates. y: An integer array, that denotes the y coordinates. + ho 10 Function Description Complete the function getTriangleArea in the editor below. The function must return an integer which indicates the area of the triangle. 8 ▾ Sample Case 0 Sample Input 0 3 oWowашоw 0 3 6 3 0 3 Sample Output 0 9 Explanation 0 Here, x = [0, 3, 6] and y = [0, 3, 0] would mean that the 3 coordinates are [0,0], [3,3], [6,0]. Thus, the area would be 9. 12 13 14 15 * 1. INTEGER_ARRAY X 16 * 2. INTEGER ARRAY Y */ 17 18 19 20 21 * * The function is expected to return an INTEGER. * The function accepts following parameters: int getTriangleArea (vector x, vector y) { 22 23 } return area; 24 25 int main() ...
Expert Answer:
Answer rating: 100% (QA)
Code int getTriangleAreavector x vector y int area 0 abc are three coordinated of ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Find the area of the region enclosed by one loop of the curve. r = 4 cos 3
-
Find the area of the region enclosed by one loop of the curve. r = sin 4
-
Find the area of the region enclosed by one loop of the curve. r = 1 + 2 sin (Inner loop)
-
The accounting records for The Skate Shed, Inc., reflected the following amounts at the end of January 2018: Prepare The Skate Shed?s multistep income statement for the fiscal year ended January 31,...
-
(a) Write a computer program (or develop an algorithm) to determine the minimum and maximum values in an array a1, a2, a3, ... , an of integers. (Here n Z+ with n > 2, and the entries in the array...
-
Find an equation for graph.
-
Consider the following cash flow profile and assume MARR is 10 percent/year. a. What does Descartes' rule of signs tell us about the IRR(s) of this project? b. What does Norstrom's criterion tell us...
-
Selected information from the payroll register of Anderson's Dairy for the week ended July 7, 20--, is shown below. The SUTA tax rate is 5.4%, and the FUTA tax rate is 0.8%, both on the first $7,000...
-
What are some similarities and differences between the Microsoft SQL Server, Oracle Database, Amazon Aurora, IBM Db2, and MySQL relational database vendors?
-
Consider an economy with three types of individuals, differing only with respect to their preferences for monuments. Individuals of the first type get a fixed benefit of 250 from the mere existence...
-
As it pertains to Construction Loans, describe the purpose of the following terms: Payout schedule (aka voucher or disbursement) within a Building Loan Agreement? Subordination Clause - why is this...
-
2 j Suppose there are three risky assets (indexed by j = 1,2,3) with the following ; and ; when regressed on the market porfolio. j Bj Ej 1 1.20 0.09 2 1.00 0.06 3 0.80 0.04 Assume that the...
-
Let t(x) = - 3x for x-1 1x2 for x 1 Determine t(-3), t(-1), t(0), and t(5).
-
What is a "Stereotype"? What is the impact of Stereotypes in the workplace? Give some examples. Q2. What is "Self-serving bias"? In the team setting, if all team members have a self-serving bias, how...
-
Simplify: 3x210x+3 3x214x+15 3x22x x2 x - x - 2 1
-
Point D'(7, 1) is the image of D(7, 6) under a translation. Determine the translation. Use non-negative numbers. A translation by units
-
The purpose of this assignment is to have you complete the Capstone project lab assignment. The lab assesses your knowledge of the skills and concepts that have been covered throughout the course....
-
Can partitioned join be used for r r.A s? Explain your answer
-
The altitude of a triangle is increasing at a rate of 1 cm/min while the area of the triangle is increasing at a rate of 2 cm2/min. At what rate is the base of the triangle changing when the altitude...
-
Use a computer algebra system to find the exact volume of the solid obtained by rotating the region bounded by the given curves about the specified line. y = sin2 x, y = 0, 0 < x < ; about y = - 1
-
Use the method of cylindrical shells to find the volume generated by rotating the region bounded by the given curves about the specified axis. (a) y = x4, y = 0, x = 1; about x = 2 (b) y = 4x - x2, y...
-
Write a program in \(\mathrm{R}\) that simulates \(b\) samples of size \(n\) from a distribution that has distribution function \[F(x)= \begin{cases}0 & x For each sample, compute the sample quantile...
-
John bought 1,000 shares of Intel stock on October 18, 2015, for $30 per share plus a $750 commission he paid to his broker. On December 12, 2019, he sells the shares for $42.50 per share. He also...
-
Laura Li, a U.S. resident, worked for three months this summer in China. What type of tax authority may be especially useful in determining the tax consequences of her foreign income?
Study smarter with the SolutionInn App