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,

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 11PE
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr