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,

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
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. 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
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,
(-100, -100, 31, 34)
35, 30 )
Number of no-overlap with the given rectangle (0, 0, 50, 50): 2
* 1
2
3
0
Sample 2:
Please enter the width and the height of the given rectangles: abc
Error: It is not integer value...Exit
Transcribed Image Text: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, (-100, -100, 31, 34) 35, 30 ) Number of no-overlap with the given rectangle (0, 0, 50, 50): 2 * 1 2 3 0 Sample 2: Please enter the width and the height of the given rectangles: abc Error: It is not integer value...Exit
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Constants and Variables
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education