Question: JAVA QUESTION (recursion) DrawingPanel class: https://docs.google.com/document/d/1wCIMItUt7vTZj3C46juYn_vayZh0Ja8TrhXdkmpMmVQ/edit?usp=sharing Draw circle: import java.awt.*; import java.util.Random; import java.util.Scanner; public class DrawCircle { public static void main(String [] args){ DrawingPanel
Part 2. Modify the circle drawing draw a picture like below. This is a recursive program that uses the fWRect method. fuRect has the same parameters as fUOval did Draw circle class import ?AYAsant.. * ; import java.uti1.Random import java.util.Scanner public class Dra Circle public static void main(String args) DrawingPanel panelnew DrawingPaneL(see,5e8): Random rand new Random) panel.setBackground (Color.LIGHT GRAY) Graphics brush = panel.getGraphics(); Scanner keyboardnew Scanner(System.in): System.out printin("Enter number of circles") int num- keyboard.nextInt); drawCircle(rand, brush, 1,1,20,2, num) public static void drawircle(Random rand, Graphics brush, int x, int y, int width, int height, int num)t return else t Color cnew Color (rand.nextInt (256), rand.nextInt (256), rand.nextInt (256)) brush.setcolor(c); brush.flloval(x.y.width height) drawCircle(rand, brush, rand.nextInt (580), rand.nextint(5ee). 28,2e num-): /fend else /end method end class The drawRect recursive method should start the x and y at 0,0. Each recursive call modifies x and y by adding 20. You also need to adjust the size of each rectangle making each successive call make the rectangle height and width reduced by 40 .Instead of asking the user for the number of circles assume that you will stop (the base case) when the width is
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
