A good answer might be:

The horizontal line across the center of the area is at Y=150/2. The top of the squares should be (300/10)/2 pixels above that, or at 150/2 - 15 (remember that Y increases going down.)

Finishing the Applet

import java.applet.Applet;
import java.awt.*;

// assume that the drawing area is 300 by 150
public class tenCircles extends Applet
{
  final int width = 300, height = 150;

  public void paint ( Graphics gr )
  { 

    gr.setColor( Color.red );
    int count =  0 ;
    while (  count < 10  )
    {
      int X = ____________;
  
      int Y = ____________;

      int R = ____________;

      gr.drawOval( ____,____,____,____ );
      count = count + 1; 
    }

  }
}

So now we have the (X, Y) coordinates of the upper left corner of each of the ten squares: The left edges of the squares are at ...

X=0, 300/10, 2*(300/10), 3*(300/10), . . . . 9*(300/10)

... and all the Y values are at (150/2 - 15).

The X and Y in the above are local variables for exclusive use of the paint method. It is correct to declare them as is done here. The blanks should be filled in with arithmetic expressions that use identifiers, not integer literals like 10, 150, 300 and so on.


QUESTION 13:

Fill in the blanks. (Hint: make use of count in computing a new X for each loop iteration.)