Concentric Circles Applet

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
Historical topic: Java appletsModern web browsers do not run Java applets. The Applet API was deprecated for removal before Java 25 and was removed in Java 26. Treat applet examples on this page as historical object-oriented/GUI examples; for new desktop interfaces use Swing where appropriate or JavaFX/OpenJFX.

Answer:

There are many interesting ways to fill in the blank. My choice is:

int count = 1;
while ( count <= 10 )
{
  circ.setRadius( (100/10)*count );
  circ.draw();
  count = count + 1;
}

Since the width (and height) of the drawing area is 200, circles can have a radius of up to 100. For ten circles, that maximum radius is divided by ten to give the size increase in each radius.

Concentric Circles Applet

Here is what the applet draws:

Embedded Java applet removed: modern browsers do not support Java applets. The surrounding source code is retained for historical study.

QUESTION 12:

It would be nice to do something with color. What two things should be done to the class for drawing colored circles?