Aligning the top plate to the bottom plate is a tricky task. If the top plate is not aligned it will cause you a bunch of headaches later on. One of the easiest ways to install it is to use a laser level.
Step 1: Anchor the laser level so that it is exactly parallel with the bottom plate. You can cut out a scrap piece of wood for this and place it on top of the bottom plate.
Step 2: The laser should extend to the end of the room and up the wall. Use this line to line up that side of the top plate and screw it in place.
Step 3: Move the laser to the other side of the room and line up the other end of the board.
Step 4: Check to make sure that the boards are straight by holding a 2x4 reaching from the top plate to the bottom plate with a level against it.
Joining the Top Plate to the Floor Joists
If the floor joists run into the top plate your job is that much easier, just screw the board into each joist. If they are parallel, you will have to run pieces of wood from the joists to the wall so the top plate can be screwed in.