Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Calculate the area of the polygon. Is there a way to modify this code to calculate the area of the polygon pictured? I don't have

Calculate the area of the polygon.

Is there a way to modify this code to calculate the area of the polygon pictured? I don't have much experience coding, and havent been able to figure it out?

---------------------------------------------

#include

using namespace std;

// (X[i], Y[i]) are coordinates of i'th point.

double polygonArea(double X[], double Y[], int n)

{

// Initialze area

double area = 0.0;

// Calculate value of shoelace formula

int j = n - 1;

for (int i = 0; i

{

area += (X[j] + X[i]) * (Y[j] - Y[i]);

j = i; // j is previous vertex to i

}

// Return absolute value

return abs(area / 2.0);

}

// Driver program to test above function

int main()

{

double X[] = {0, 2, 4};

double Y[] = {0, 3, 7};

int n = sizeof(X)/sizeof(X[0]);

cout

}

image text in transcribed

These are the hints below provided:

image text in transcribedimage text in transcribed

(6/5, 11/2) (9/2, 5) (3,4) (11/2,7/2) (16/5, 3/2) (6/5, 11/2) (9/2, 5) (3,4) (11/2,7/2) (16/5, 3/2)

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

Effective Delivery Effective

Answered: 1 week ago