Create a Java project and write a java program that models a set of geometric shapes....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Create a Java project and write a java program that models a set of geometric shapes. The program should create TWO rectangles and TWO circles and perform the following tasks: 1. For each shape randomly generate its' point position (x, y), as Point object. Knowing that a rectangle use integers coordinates and circles (or ellipses) uses double values. 2. For each rectangle, prompt the user to enter the dimensions: height and width. 3. For each circle, prompt the user to enter the radius. Hint: utilize Ellipse2D class/object available in Java API platform 4. Create the rectangle and circles objects using the provided input. 5. Identify and display the rectangle or circle (ellipse) with the largest area. Define functions to compute area of each shape, and a function to find the largest area among all shapes. 6. Identify and display any rectangles or circles (ellipses) that intersect each other. 7. Identify and display if any shape is inside another. Your solution should include appropriate classes and methods to handle the rectangles, ellipses, and intersection checking. You can utilize the Rectangle, Ellipse2D, and Point classes from the Java API platform for this assignment. Sample runs Sample Run 1: Sample Run 2: Enter Rectangle 1 height and width: 200 30 Enter Rectangle 2 height and width: 50 60 Enter Circle 1 radius: 100 Enter Circle 2 radius: 20 Rectangle 1 coordinate: (91.0, 1.0) Rectangle 2 coordinate: (76.0, 76.0) Circle 1 coordinate: (92.0, 75.01 Circle 2 coordinate: (74.0, 52.01 Largest Shape is: Circle 1 with area: 31415.927 Rectangle 1 and Rectangle 2 intersect. Rectangle 1 and Circle 1 intersect. Rectangle 2 and Circle 1 intersect. Rectangle 2 and Circle 2 intersect. BUILD SUCCESSFUL (total times 7 seconds) zun Enter Rectangle 1 height and width: 26 150 Enter Rectangle 2 height and width: 93 50 Enter Circle 1 radius: 40 Enter Circle 2 radius: 300 Rectangle 1 coordinate: (65.0, 65.0) Rectangle 2 coordinate: (75.0, 75.0) Circle i coordinate: (54.0, 63.0) Circle 2 coordinate: (83.0, 75.0) Largest Shape is: Circle 2 with area: 282743.339 Rectangle 1 and Circle 1 intersect. Rectangle 2 and Circle 1 intersect. Circle 1 and Circle 2 intersect. BUILD SUCCESSFUL (total time: 22 seconds) Create a Java project and write a java program that models a set of geometric shapes. The program should create TWO rectangles and TWO circles and perform the following tasks: 1. For each shape randomly generate its' point position (x, y), as Point object. Knowing that a rectangle use integers coordinates and circles (or ellipses) uses double values. 2. For each rectangle, prompt the user to enter the dimensions: height and width. 3. For each circle, prompt the user to enter the radius. Hint: utilize Ellipse2D class/object available in Java API platform 4. Create the rectangle and circles objects using the provided input. 5. Identify and display the rectangle or circle (ellipse) with the largest area. Define functions to compute area of each shape, and a function to find the largest area among all shapes. 6. Identify and display any rectangles or circles (ellipses) that intersect each other. 7. Identify and display if any shape is inside another. Your solution should include appropriate classes and methods to handle the rectangles, ellipses, and intersection checking. You can utilize the Rectangle, Ellipse2D, and Point classes from the Java API platform for this assignment. Sample runs Sample Run 1: Sample Run 2: Enter Rectangle 1 height and width: 200 30 Enter Rectangle 2 height and width: 50 60 Enter Circle 1 radius: 100 Enter Circle 2 radius: 20 Rectangle 1 coordinate: (91.0, 1.0) Rectangle 2 coordinate: (76.0, 76.0) Circle 1 coordinate: (92.0, 75.01 Circle 2 coordinate: (74.0, 52.01 Largest Shape is: Circle 1 with area: 31415.927 Rectangle 1 and Rectangle 2 intersect. Rectangle 1 and Circle 1 intersect. Rectangle 2 and Circle 1 intersect. Rectangle 2 and Circle 2 intersect. BUILD SUCCESSFUL (total times 7 seconds) zun Enter Rectangle 1 height and width: 26 150 Enter Rectangle 2 height and width: 93 50 Enter Circle 1 radius: 40 Enter Circle 2 radius: 300 Rectangle 1 coordinate: (65.0, 65.0) Rectangle 2 coordinate: (75.0, 75.0) Circle i coordinate: (54.0, 63.0) Circle 2 coordinate: (83.0, 75.0) Largest Shape is: Circle 2 with area: 282743.339 Rectangle 1 and Circle 1 intersect. Rectangle 2 and Circle 1 intersect. Circle 1 and Circle 2 intersect. BUILD SUCCESSFUL (total time: 22 seconds)
Expert Answer:
Answer rating: 100% (QA)
Below is a Java program that models a set of geometric shapes rectangles and circles and performs the specified tasks import javaawtgeomEllipse2D import javaawtRectangle import javaawtPoint import jav... View the full answer
Related Book For
Numerical Methods With Chemical Engineering Applications
ISBN: 9781107135116
1st Edition
Authors: Kevin D. Dorfman, Prodromos Daoutidis
Posted Date:
Students also viewed these programming questions
-
ABC Veterinary Practice provides boarding services. For its "Regular Suite," it estimates its costs as follows: Variable cost per night (labor, food, electricity, nightly treat, etc.) = $15 Fixed...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Comprehensive comparison between Linux Kernel and windows Kernel? Comprehensive comparison between Linux System and windows System? Comprehensive comparison between Linux Distributions and windows...
-
Codominance observable effect on the phenotype of a heter neither allele is recessive-both alleles are dominant. 6. Which of the genotypes results in a blood type that provides clear evidence of...
-
What specific features did the Mosaic browser include that were not available in earlier browsers? How did these features help make the Web accessible to a larger audience?
-
SuperCity is a large retailer of electronics and appliances. The store sells three different models of TVs that are ordered from different manufacturers. The demands, costs, and storage requirements...
-
True or False. The force transmitted to the foundation of an isolator with rigid foundation can never be infinity.
-
The table below shows the account balances of Novations, Inc., at the beginning and end of the company's accounting period. The following additional information is available: (a) All purchases and...
-
9. An object with a mass of 78kg is on a magnesium material floating on the water. The density of the magnesium is 782 kg/m3 and is barely out of the surface of the water. Determine the volume of the...
-
Explain how personal selling can help solve the problem of information overload.
-
At public TV station, QQTV. the Membership Department currently keeps donation information on database which runs on their local area network. QQTV would like to pursue more direct marketing and...
-
A bunch of change contains nickels, dimes, and quarters. There is the same number of dimes and quarters, and there are eight more nickels than either dimes or quarters. How many dimes are there if...
-
Solve the systems in Problems \(27-38\) by the addition method. \(\left\{\begin{array}{l}5 s_{1}+2 s_{2}=23 \\ 2 s_{1}+7 s_{2}=34\end{array}ight.\)
-
Given the matrices in Problems 36-39, perform elementary row operations to obtain zeros above and below the 1 in the third column without changing the entries in the first or second columns. [c] = 10...
-
Suppose a car rental agency gives the following options: Option A: \(\$ 40\) per day plus \(50 otin\) per mile Option B: Flat \(\$ 60\) per day with unlimited mileage At what mileage are both rates...
-
Given the matrices in Problems 32-35, perform elementary row operations to obtain a 1 in the third row, third column without changing the entries in the first two columns....
-
Q7. National Hospitality Supply Co. has traditionally manufactured a number of different standard items for hotels and motels. It is now exploring an outsourcing decision for Coffe Machine that it...
-
Write electron configurations for the following ions, and determine which have noble-gas configurations: (a) Cd2+ (b) p3- (c) Zr4+ (d) Ru3+ (e) As3- (f) Ag+
-
Consider the following program: What system of equations is being solved by this method? What method is used for the solution? Will this program converge to a solution? To save you time, we have...
-
Set up a forward Euler scheme to compute the concentration for a batch reactor with k A+B=C k_1 k2 B+C=D k_2 (4.6.18) (4.6.19)
-
Perform one time step of the predictorcorrector method with h = 0.01 for the differential equation dy dx = cos(x) y2 sin(x); y(1)=10 -
-
Three rival professors teaching English 1 all claim the honor of having the best students. To settle the issue, eight students are randomly drawn from each class and given the same exam. The exams...
-
Fill in the Blank. The Laplace transform method converts a differential equation into a(n)__________equation.
-
A roller cam is used to impart a periodic motion to the base of the spring-mass system shown in Fig. 4.41. If the coefficient of friction between the mass and the surface is \(\mu\), find the...
Study smarter with the SolutionInn App