Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a function that will draw a given number of filled rectangles (using addRe

ID: 3607127 • Letter: W

Question

write a function that will draw a given number of filled rectangles (using addRectFilled), of random width and random height (both from 1 up to a specified maximum), and of random colour, drawn at random points on an empty black canvas of a given width and height. The total number of rectangles drawn that are squares must be printed in white on the canvas, positioned near the top, and approximately in the middle. In addition, the total number of rectangles that are 1 pixel in width or in height must also be printed in white, below the previous printed line. This is supposed to be in JES. Any help I can get would be appreciated, thanks.

Explanation / Answer

public class Knapsack { public static final int[] zeroOneKnapsack(int[] values, int[] weights, int capacity) { if (weights.length != values.length) return null; int height = weights.length + 1; // weights==values int width = capacity + 1; int[][] output = new int[height][width]; for (int i = 1; i