How far have you got, and where are you stuck?
The code will be very similar to the code you posted.