SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Y Daniel Lang
Chapter:
And Polymorphism
Exercise:
Programming Excercises
Question:4 | ISBN:978013274719 | Edition: 6

Question

(Geometry: find the bounding rectangle) A bounding rectangle is the minimum rectangle that encloses a set of points in a two-dimensional plane, as shown in Figure 12.16. Write a method that returns a bounding rectangle for a set of points in a two-dimensional plane, as follows:
           def getRectangle(points):
You defined the Rectangle2D class in Exercise 8.19. Write a test program that prompts the user to enter the points as x1 y1 x2 y2 x3 y3 ... in one line, and displays the bounding rectangle’s center, width, and height. Here is a sample run:

Enter the points: 1.0 2.5 3 4 5 6 7 8 9 10
The bounding rectangle is centered at (5.0, 6.25) with width 8.0 and height 7.5

FIGURE 12.16 Points are enclosed inside a rectangle.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Sorry the answer is not available at the moment…

If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.

Spread the 'tradition of sharing'.