Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. [10 marks] (Rectangle) Given the (x,y)-coordinates of the four vertices of a possible rectangle, i.e. (x1, y1), (x2, y2), (x3, y3), (x4, y4), we

1. [10 marks] (Rectangle) Given the (x,y)-coordinates of the four vertices of a possible "rectangle", i.e. (x1, y1), (x2, y2), (x3, y3), (x4, y4), we are able to find the area of the rectangle. It is known that the area A can be computed by multiplying together the "length" and "width" of the rectangle. The length of a line between two points P5 = (x5, y5) and P6 = (x6, y6) can be computed as (x6-x5)2 + (y6-y5)2. However, there may be doubt on whether the given "rectangle" is really a rectangle. For example, (3.8,1.1), (13.4,8.3), (10.4,12.3), (0.8,5.1) is a rectangle, but (3.5,1.2), (13.4,8.3), (10.7,12.2), (0.8,5.1) is not a rectangle, but just a parallelogram.

Write the pseudo-code to compute and return the area of the "rectangle" (quite easy), and in case that it is not a real rectangle, return zero instead of the area (more difficult). You can assume that there is no degenerated situation. The input and output for the pseudo-code is given here:

Input: coordinates for four vertices: (x1, y1), (x2, y2), (x3, y3), (x4, y4) of a potential rectangle. Output: area A for a rectangle or zero for a non-rectangle.

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

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions