Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a Java project and write a java program that models a set of geometric shapes. The program should create TWO rectangles and TWO
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)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started