Question: Write a program that prompts the user to enter the center x-, y-coordinates, width, and height of two rectangles and determines whether the second rectangle
Write a program that prompts the user to enter the center x-, y-coordinates, width, and height of two rectangles and determines whether the second rectangle is inside the first or overlaps with the first, as shown in Figure 3.9. Test your program to cover all cases.

Here are the sample runs:

wl wl w2 w2 (xl, yl) h1 (x1, yl) h2 (x2, y2) h2 (2, 2) h1 (a) (b) Enter rl's center x-, y-coordinates, width, and height: 2.5 4 2.5 43 -Enter Enter r2's center x-, y-coordinates, width, and height: 1.5 5 0.5 3 JEnter r2 is inside rl Enter rl's center x-, y-coordinates, width, and height: 1 2 3 5.5 -Enter Enter r2's center x-, y-coordinates, width, and height: 3 4 4.5 5 r2 overlaps r1 JEnter Enter rl's center x-, y-coordinates, width, and height: 1 2 3 3 -Erter Enter r2's center x-, y-coordinates, width, and height: 40 45 3 2 r2 does not overlap r1 JEnter
Step by Step Solution
3.43 Rating (159 Votes )
There are 3 Steps involved in it
Output Enter rls x y coordinates width and height 1 2 3 5 5 Enter r2s x y coordinates widt... View full answer
Get step-by-step solutions from verified subject matter experts
