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: 72% (11 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
-
Refer to the data for Durall Company in the preceding case. Assume that the company uses the FIFO method. Required: 1. Prepare a report for the Forming Department for October showing how much cost...
-
Flowchart symbols represent what aspect of a system?
-
John's Custom Computer Shop (JCCS) assembles computers for both individual and corporate customers. The company is organized into two divisions: Personal and Business. Once a computer is built, it is...
-
Suppose a principal of $10,000 is compounded (a) annually, (b) quarterly, (c) monthly, (d) weekly, and (e) daily, at a per annum interest rate of 6.5%. Generate a table of the corresponding effective...
-
Match the following and select the correct option. Height of Binary search tree(in worst o([log ]-1) 1 a (2n+1) case) Height of Ternary tree b O(n) Height of B-tree(when c minimum degree, -2) (log,...
-
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...
-
After 27 months of quarterly compounding, a $3000 debt had grown to $3810. What effective rate of interest was being charged on the debt?
-
Name one type of asset that may not be included at its historic cost in financial statements?
-
Express accounting profit in the form of a simple equation.
-
To determine whether accounts payable are complete, an auditor performs a test to verify that all merchandise received is recorded. The population of documents for this test consists of all a....
-
State which account should be debited and which account should be credited in respect of each of the following terms: (a) cash paid to a supplier (b) office rent paid by cheque (c) cash sales (d)...
-
Suggest two reasons why this chapter is important for non-accountants.
-
Explain why the regression equation is a better source of predictions than is the mean.
-
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...
-
Explain how investors react to changes in a company's dividend payout policy. Discuss what a firm's payout policy indicates about the financial status of a company. Discuss how taxes impact an...
-
Hi, please help with this question. I was able to answer part a but have gotten stuck on B and C. Thank you (Efficiency analysis) The Brenmar Sales Company had a gross profit margin(gross...
-
John currently has a portfolio of shares giving a return of 20% with a risk of 10%. He is considering a new investment which gives a return of 20% with a risk of 12%. The coefficient of correlation...
Study smarter with the SolutionInn App