Start off by drawing a picture:
Code:
<----w---->
/\+----+----+
| | | |
| | | |
h +----+----+
| | | |
| | | |
\/+----+----+
Now write an equation for the length of fence used:
3*w+3*h=400
Now write an equation for the area of the pen:
A=w*h
Solve the first equation for h so we can substitute it into the second (since the problem wants the equation in terms of w only).
3w+3h=400
3h=400-3w
h=400/3 - w
Substitute this into the second equation:
A=w*h
A=w*(400/3 - w)
A=(400w/3)-w^2
From here you should be able to solve for the width that gives the max area.