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

Hi Everybody, I need the answer for this question in Java and I need the program

ID: 668766 • Letter: H

Question

Hi Everybody,

I need the answer for this question in Java and I need the program to be run in the netbeans and

please I need the answer before this friday

13.6 (Concentric Circles Using Method drawArc) Write an application that draws a series of eight
concentric circles. The circles should be separated by 10 pixels. Use Graphics method drawArc.

Create an application that provides a solution for problem 13.6 by modifying the solution as follows.

Provide for starting the drawings at random location (i.e., the x-y coordinate must be calculated randomly).

Provide a random color for each circle.

Provide a random diameter for each circle (i.e., should not default to 20 pixels greater than previous as specified in the text).

Note:

Make all other necessary modifications necessary to run the application.

Explanation / Answer

Hi,

Below is the solution to your problem:

//Program to draw concentric circles with random colors and random diameter
import java.awt.Graphics;
import javax.swing.JPanel;

public class ConcentricCirclesClass extends JPanel
{
// draw eight Circles
public void paintComponent( Graphics g )
{
Random random = new Random();
super.paintComponent( g );

// Creates 8 concentric circles
for ( int topLeft = 0; topLeft < 80; topLeft += 10 )
{
int radius = 160 - ( topLeft * 2 );
int r = random.nextInt(255);
int gr = random.nextInt(255);
int b = random.nextInt(255);
Color c = new Color(r,gr,b);
g.setColor(c);
g.drawArc( topLeft + 10, topLeft + 25, radius, radius, 0, 360 );
}
}
}

// This program now draws concentric circles
import javax.swing.JFrame;

public class ConcentricCirclesTestProgram extends JFrame {
/**
* @param args
*/
public static void main(String[] args) {

JFrame frame=new JFrame("Concentric Circles Program");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

ConcentricCirclesClass cCirclesJPanel = new ConcentricCirclesClass();
frame.add(cCirclesJPanel);
frame.setSize(200,250);
frame.setVisible(true);

}
}

Hope this helps....HAPPY ANSWERING!!!!!!!!!!