You will need to import the graphics package into your BlueJ project. Write a Java application RandomRectangles which prompt for a positive integer then draws that number of random rectangles. If the input is not a positive integer, the program will display a message and prompt for input again until a positive integer is entered. The program also finds the rectangle with the smallest area and display the number of the rectangles and the smallest area. Draw the squares in red. After you have drawn all the rectangles, fill the rectangle with the smallest area with yellow. Use the predefined colors from the Color class. If more than one rectangle has the smallest area, use the last one with that area as the smallest. You should declare and use the following constants: public static final int MAX_X = 100; public static final int MAX_Y = 500; public static final int MIN_WIDTH = 30; public static final int MAX_WIDTH = 100; public static final int MIN_HEIGHT = 20; public static final int MAX_HEIGHT = 80; public static final int GENERATOR_SEED = 202210; All rectangles have random widths and heights at random locations. The (x, y) coordinates are for the upper-left corner of the rectangle. Make the x coordinate a random number between 0 (inclusive) and 100 (exclusive), the y coordinate a random number between 0 (inclusive) and 500 (exclusive). Make the width a random value between 30 (inclusive) and 100 (exclusive), the height a random value between 20 (inclusive) and 80 (exclusive). You must use the given seed GENERATOR_SEED, 202210, to generate the random numbers. For each rectangle, generate the random values in this order: x coordinate, y coordinate, width, and height. All values are integers. You must use one for loop to draw the rectangles and find the smallest one, and not store the rectangles in an array list or an array. You must use one Scanner object and call Scanner methods to process input. You cannot use try- catch statement or call any parse method. The Codecheck server will run your program three times using different input sets and the expected output is attached at the end of t
You will need to import the graphics package into your BlueJ project. Write a Java application RandomRectangles which prompt for a positive integer then draws that number of random rectangles. If the input is not a positive integer, the program will display a message and prompt for input again until a positive integer is entered. The program also finds the rectangle with the smallest area and display the number of the rectangles and the smallest area. Draw the squares in red. After you have drawn all the rectangles, fill the rectangle with the smallest area with yellow. Use the predefined colors from the Color class. If more than one rectangle has the smallest area, use the last one with that area as the smallest. You should declare and use the following constants: public static final int MAX_X = 100; public static final int MAX_Y = 500; public static final int MIN_WIDTH = 30; public static final int MAX_WIDTH = 100; public static final int MIN_HEIGHT = 20; public static final int MAX_HEIGHT = 80; public static final int GENERATOR_SEED = 202210; All rectangles have random widths and heights at random locations. The (x, y) coordinates are for the upper-left corner of the rectangle. Make the x coordinate a random number between 0 (inclusive) and 100 (exclusive), the y coordinate a random number between 0 (inclusive) and 500 (exclusive). Make the width a random value between 30 (inclusive) and 100 (exclusive), the height a random value between 20 (inclusive) and 80 (exclusive). You must use the given seed GENERATOR_SEED, 202210, to generate the random numbers. For each rectangle, generate the random values in this order: x coordinate, y coordinate, width, and height. All values are integers. You must use one for loop to draw the rectangles and find the smallest one, and not store the rectangles in an array list or an array. You must use one Scanner object and call Scanner methods to process input. You cannot use try- catch statement or call any parse method. The Codecheck server will run your program three times using different input sets and the expected output is attached at the end of t
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 7PE
Related questions
Question
You will need to import the graphics package into your BlueJ project.
Write a Java application RandomRectangles which prompt for a positive integer then draws
that number of random rectangles. If the input is not a positive integer, the program will display
a message and prompt for input again until a positive integer is entered. The program also finds
the rectangle with the smallest area and display the number of the rectangles and the smallest
area.
Draw the squares in red. After you have drawn all the rectangles, fill the rectangle with the
smallest area with yellow. Use the predefined colors from the Color class. If more than one
rectangle has the smallest area, use the last one with that area as the smallest.
You should declare and use the following constants:
public static final int MAX_X = 100;
public static final int MAX_Y = 500;
public static final int MIN_WIDTH = 30;
public static final int MAX_WIDTH = 100;
public static final int MIN_HEIGHT = 20;
public static final int MAX_HEIGHT = 80;
public static final int GENERATOR_SEED = 202210;
All rectangles have random widths and heights at random locations. The (x, y) coordinates are
for the upper-left corner of the rectangle. Make the x coordinate a random number between 0
(inclusive) and 100 (exclusive), the y coordinate a random number between 0 (inclusive) and 500
(exclusive). Make the width a random value between 30 (inclusive) and 100 (exclusive), the
height a random value between 20 (inclusive) and 80 (exclusive).
You must use the given seed GENERATOR_SEED, 202210, to generate the random numbers.
For each rectangle, generate the random values in this order: x coordinate, y coordinate, width,
and height. All values are integers.
You must use one for loop to draw the rectangles and find the smallest one, and not store the
rectangles in an array list or an array.
You must use one Scanner object and call Scanner methods to process input. You cannot use try-
catch statement or call any parse method.
The Codecheck server will run your program three times using different input sets and the
expected output is attached at the end of the document.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 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
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT