The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 399 Weeks Ago, 1 Day Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Write a program named SquaredCircles.java that draws the figure shown below.
Submit your SquaredCircles.java to Canvas, you do not need to submit DrawingPanel.
The DrawingPanelA????1s size is 400 A????1 400 pixels and its background color is cyan. It contains four figures of concentric
yellow circles with black outlines, all surrounded by a green rectangle with a black outline. The four figures on your
DrawingPanel should have the properties shown in the table below.
Description (x,y) position Size of subfigures Number of circles Number of rows/cols
Top left (0, 0) 100 A????1 100 5 1 A????1 1
Bottom left (10, 120) 24 A????1 24 4 5 A????1 5
Top right (150, 20) 40 A????1 40 5 6 A????1 6
Bottom right (130, 275) 36 A????1 36 3 3 A????1 3
import java.awt.*;
public class SquaredCirclesStarter {
 Â
public static void main( String[] args ) {
DrawingPanel panel = new DrawingPanel(400, 400);
Graphics g = panel.getGraphics();
 Â
panel.setBackground( Color.CYAN );
 Â
drawCircles( g, 0, 0, 100, 5 );
drawCircles( g, 10, 120, 24, 4);
drawCircles( g, 150, 20, 40, 5);
drawCircles( g, 130, 275, 36, 3);
 Â
}
 Â
// draws one squared circle figure.
public static void drawCircles( Graphics g, int x, int y,
int width, int numCircles ) { Â Â
// draw square background
g.setColor( Color.GREEN );
g.fillRect( x, y, width, width );
 Â
// draw circles background
g.setColor( Color.YELLOW );
g.fillOval( x, y, width, width );
 Â
// draw circles from outside to inside
///////////////// Your code goes here
g.setColor( Color.BLACK );
for( int i = 0; i < numCircles; i++ ) {
  g.drawOval( x + i * width / (2 * numCircles),
        y + i * width / (2 * numCircles),
        width - i * width / numCircles,
        width - i * width / numCircles);
}
 Â
 Â
// box it in
g.drawRect( x, y, width, width );
 Â
// horizontal line through the middle
///////////////// Your code goes here
g.drawLine( x, y + width / 2, x+ width, y + width / 2 );
 Â
// vertical line through the middle  Â
///////////////// Your code goes here
g.drawLine( x +width / 2, y, x + width / 2, y + width );
}
}
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll