Write a program that prompts the user to enter the center x-, y-coordinates, width, and height of
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 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:
Transcribed Image Text:
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
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 77% (9 reviews)
Output Enter rls x y coordinates width and height 1 2 3 5 5 Enter r2s x y coordinates widt...View the full answer
Answered By
Allan Simiyu
I am an adroit Writer. I am a dedicated writer having worked as a writer for 3 years now. With this, I am sure to ace in the field by helping students break down abstract concepts into simpler ideas.
5.00+
8+ Reviews
54+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Write a program that prompts the user to enter three cities and displays them in ascending order. Here is a sample run: Enter the first city: Chicago JEnter Enter the second city: Los Angeles JEnter...
-
Write a program that prompts the user to enter two strings and tests whether the second string is a substring of the first string. (Don?t use the indexOf method in the String class.) Analyze the time...
-
Write a program that prompts the user to enter a three-digit integer and determines whether it is a palindrome number. A number is palindrome if it reads the same from right to left and from left to...
-
Estimate the cash value of a life insurance policy as of December 31, 2016 based on the following information: Cash value as of January 2016 $90,000 Total premium during the year $ 8,000 Term life...
-
Find the lengths of the arcs subtended by the angles θ and Ï radians in Figure 20. 0.9 FIGURE 20 Circle of radius 4
-
Unroll this loop once and schedule it for a 2-issue static superscalar processor. Assume that the loop always executes an even number of iterations. You can use registers R10 through R20 when...
-
Consider the following cash flow diagram. What is the value of \(X\) if the internal rate of return is 15 percent? a. \(\$ 246\) b. \(\$ 255\) c. \(\$ 281\) d. \(\$ 290\) 0 $400 X X 1 2
-
Post-Balance-Sheet Events At December 31, 2010, Coburn Corp. has assets of $10,000,000, liabilities of $6,000,000, common stock of $2,000,000 (representing 2,000,000 shares of $1 par common stock ),...
-
Three friends, A, B, and C, start a business with investments in the ratio of 4:3:5, respectively. A invested $5,000, and all three of them agree to share profits in the ratio of their investments....
-
1. The total payroll tax expense incurred by the employer on salaries and wages paid during the quarter ended December 31 was.....................$ 2. The total payroll tax expense incurred by the...
-
Suppose a right triangle is placed in a plane as shown below. The right-angle point is placed at (0, 0), and the other two points are placed at (200, 0), and (0, 100). Write a program that prompts...
-
Write a program that prompts the user to enter the center coordinates and radii of two circles and determines whether the second circle is inside the first or overlaps with the first, as shown in...
-
Y in the regression equation is ____ and X is the ____.
-
1-Your companys revenues were $2 million this year. You paid out $500,000 in salaries and your only other cash outflow was the purchase of a piece of construction equipment for $1 million that is to...
-
Zackie Company has recently allowed its customers to make purchases on credit. The terms are 2/10, n/30. Unfortunately, Zackie Company has found that not all of its credit customers pay their bills...
-
A bullet of mass 20 grams is fired into a pendulum bob of mass 600 grams initially hanging at rest on a string of length 2.0 m. The bullet lodges in the pendulum bob. What minimum speed must the...
-
You have $29,000 in a brokerage account, and you plan to deposit an additional $1,000 at the end of every future year until your account totals $100,000. You expect to earn 10% annually on the...
-
Bristol plc pays corporation tax at a rate of 25%. Tax is paid the year after each cash flow. Please complete the following Calculate the tax cashflows Calculate the net cash flow for each year...
-
Explain why the increase or decrease in cash is not equal to the profit or loss reported in the income statement. How can a company's cash balance decrease when the company has earned profit?...
-
For the following arrangements, discuss whether they are 'in substance' lease transactions, and thus fall under the ambit of IAS 17.
-
Define a new class named MyBST that extends the BST class with the following method: // Returns true if the tree is an AVL tree public boolean isAVLTree() Use...
-
The MyLinkedList class used in Listing 24.5 is a one-way directional linked list that enables one-way traversal of the list. Modify the Node class to add the new data field name previous to refer to...
-
You can find the kth smallest element in a BST in O(n) time from an inorder iterator. For an AVL tree, you can find it in O(log n) time. To achieve this, add a new data field named size in...
-
Give a brief description of a product launch for any business firm/organization that you want to open or would want to work with in future. Provide at least two appropriate 'Call to Actions' for the...
-
Briefly explain the organizational pattern of a 'Feature Article'? Why is 'tension' so important in a Feature article?
-
Cemex has an enviable past, a struggling present and an uncertain future. The company boasts of a century-old history and has weathered many a storm in an unfriendly Mexican business environment....
Study smarter with the SolutionInn App