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

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 panel = new DrawingPanel(500,500);
Random rand = new Random();
panel.setBackground(Color.LIGHT_GRAY);
Graphics brush = panel.getGraphics();
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter number of circles");
int num= keyboard.nextInt();
drawCircle(rand, brush, 1,1,20,20, num);
}
public static void drawCircle(Random rand, Graphics brush, int x, int y, int width, int height, int num){
if(num==0)
return ;
else {
Color c = new Color (rand.nextInt(256), rand.nextInt(256), rand.nextInt(256));
brush.setColor(c);
brush.fillOval(x,y,width,height);
drawCircle(rand, brush, rand.nextInt(500), rand.nextInt(500), 20,20,num-1);
}//end else
}//end method
}//end class
 JAVA QUESTION (recursion) DrawingPanel class: https://docs.google.com/document/d/1wCIMItUt7vTZj3C46juYn_vayZh0Ja8TrhXdkmpMmVQ/edit?usp=sharing Draw circle: import java.awt.*; import

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!