Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in Java that finds the area of ANY quadrilateral, either convex or concave. You should require that the points must be entered

Write a program in Java that finds the area of ANY quadrilateral, either convex or concave. You should require that the points must be entered in a particular order (be sure to inform the user of the form required): starting with any point as point 1, point 1 must be followed by point 2 (so the line from point 1 to point 2 is a side of the figure), followed by point 3 (so the line from point 2 to point 3 is a side), then followed by point 4 (so the lines from point 3 to point 4 is a side AND the line from point 4 to point 1 is a side). You should further require that a least one diagonal connect points 1 and 3 (shown in red in the figures below) and that no 3 points be collinear. Here is a sample input prompt header:

Enter the 4 points so that the first to the second is a side,

the second to the third is a side,

the third to the fourth is a side

the fourth to the first is a side

AND the first to the third is a diagonal INSIDE the figure.

No 3 points can be collinear

Enter the x- and y-coordinates of the first point

. . .

Assume that the user follows the directions, so no exceptions need be thrown. Note that in the figures below the diagonal divides the quadrilateral into two triangles, so you can find the areas of both triangles (using Herods method in Assignment 7 above) and add them together. In this part you will not need the distinctions in the previous part, as it allows you to find the area of any convex or concave quadrilateral. Hence, in this part you only need the Point class, the Quadrilateral class (NOT abstract), and a separate class for the main routine to prompt the user for the 4 points.

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

Students also viewed these Databases questions

Question

1 notent = tht 1 notent = tht

Answered: 1 week ago

Question

Write short notes on Interviews.

Answered: 1 week ago

Question

1. How might volunteering help the employer and the employee?

Answered: 1 week ago