• In terms of `houseX`, and `houseW` what is the X value of the center?
• center of the House = `houseX` + `houseW`/2
• In terms of the previous answer, and the width of the door, `doorW`, what is the X value of the left edge of the door, `doorX` ?
• `doorX` = center - `doorW`/2 = `houseX` + `houseW`/2- `doorW`/2

# Calculating a Coordinate.

These calculations can be plugged into the declaration section of the applet:

```import javax.swing.JApplet;
import java.awt.*;

// assume that the drawing area is 350 by 250
public class HouseRectangles2 extends JApplet
{
final int width  = 350, height = 250;
final int houseX =  65, houseY = 100, houseW = 110, houseH = 110 ;
final int               doorY  = 165, doorW  =  25, doorH  =  40 ;
final int lWindX =  90, lWindY = 115, lWindW =  30, lWindH =  30 ;
final int rWindX = 130, rWindY = 115, rWindW =  30, rWindH =  30 ;
final int trunkX = 255, trunkY = 100, trunkW =  10, trunkH = 100 ;

final int doorX  = houseX + houseW/2 - doorW/2;

public void paint ( Graphics gr )
{
gr.setColor( Color.orange );    // there is no Color brown
gr.drawRect( houseX , houseY , houseW, houseH); // house
gr.drawRect( doorX  , doorY  , doorW , doorH ); // door
gr.drawRect( lWindX , lWindY , lWindW, lWindH); // lwind
gr.drawRect( rWindX , rWindY , rWindW, rWindH); // rwind
gr.fillRect( trunkX , trunkY , trunkW, trunkH); // trunk
}
}
```

Here is the revised picture that it produces:

If you see this, your browser is not running Java.

The same sort of calculation could be done with other points in the picture. The windows could be better centered, for example. But let's move on to the tree. Look at the graph paper sketch again (click here to see it) and estimate the location of the upper left corner, the width, and the height of the rectangle that contains the tree's foliage,

### QUESTION 6:

Fill in the blanks:

• X:
• Y:
• width:
• height: