2. To Do: Write a Java program that given the dimensions of a rectangle, and the number of random rectangles to generate, calculates the number of randomly generated rectangles with no-overlap with the given rectangle. Your program should ask the user to enter the number of random rectangles to generate as well as the dimensions of the given rectangle. The program should display a table which includes information about each randomly generated rectangle and the number of contained corners in the given rectangle. Finally, it should indicate the number of randomly generated rectangles with no-overlap. See the sample runs. 3. Additional requirements: 1. Number of generated rectangles should be greater than zero. 2. The position of the upper left corner of the given rectangle is (0, 0) and its dimensions should range between 10 and 100. 3. The upper left corner coordinates of each random rectangle are generated randomly to be less than 100 and greater than -100. Besides, its generated random dimensions should range between 30 and 50. 4. Two rectangle objects are constructed only once. Then just update the location and the dimensions for each generated rectangle using Rectangle API methods. 5. Use the Point and Rectangle API (java.awt) methods whenever is applicable. 6. Stop running the program if the input data type is incorrect. However, keep reading if the user enters invalid input range 4. Hints: Browse the API Documentation to see all the features of the following classes: Point, Rectangle, String. 5. Sample runs ➤ Sample 1: Please enter the width and the height of the given rectangle: 50 50 Please enter how many rectangles you would like to generate: -4 Error: Enter integer value> 0... Try Again Please enter how many rectangles you would like to generate: 3 **** * Rect# * R(x, w, h) * contained corners 532, 35) *(-5, -7, * (-100, 20, 35, 30) (-100, -100, 31, 34 ) Number of no-overlap with the given rectangle (0, 0, 50, 50) 2 * 1 *2 *3 y, 4 0 0 Sample 2: Please enter the width and the height of the given rectangles: abc. Error: It is not integer value... Exit
2. To Do: Write a Java program that given the dimensions of a rectangle, and the number of random rectangles to generate, calculates the number of randomly generated rectangles with no-overlap with the given rectangle. Your program should ask the user to enter the number of random rectangles to generate as well as the dimensions of the given rectangle. The program should display a table which includes information about each randomly generated rectangle and the number of contained corners in the given rectangle. Finally, it should indicate the number of randomly generated rectangles with no-overlap. See the sample runs. 3. Additional requirements: 1. Number of generated rectangles should be greater than zero. 2. The position of the upper left corner of the given rectangle is (0, 0) and its dimensions should range between 10 and 100. 3. The upper left corner coordinates of each random rectangle are generated randomly to be less than 100 and greater than -100. Besides, its generated random dimensions should range between 30 and 50. 4. Two rectangle objects are constructed only once. Then just update the location and the dimensions for each generated rectangle using Rectangle API methods. 5. Use the Point and Rectangle API (java.awt) methods whenever is applicable. 6. Stop running the program if the input data type is incorrect. However, keep reading if the user enters invalid input range 4. Hints: Browse the API Documentation to see all the features of the following classes: Point, Rectangle, String. 5. Sample runs ➤ Sample 1: Please enter the width and the height of the given rectangle: 50 50 Please enter how many rectangles you would like to generate: -4 Error: Enter integer value> 0... Try Again Please enter how many rectangles you would like to generate: 3 **** * Rect# * R(x, w, h) * contained corners 532, 35) *(-5, -7, * (-100, 20, 35, 30) (-100, -100, 31, 34 ) Number of no-overlap with the given rectangle (0, 0, 50, 50) 2 * 1 *2 *3 y, 4 0 0 Sample 2: Please enter the width and the height of the given rectangles: abc. Error: It is not integer value... Exit
Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter8: Advanced Data Handling Concepts
Section: Chapter Questions
Problem 3GZ
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 4 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning