We try to be careful around here about doing other people's homework, because if we do it, then people aren't learning.
My suggestion is, if it really is a midterm question then ask your teacher for the solution. He/She definitely will have one which they used as a template to mark your exam.
Furthermore, I strongly believe that programming is something that is learned through "doing", not from reading code and trying to memorize. Therefore, my next suggestion is that you try to do the question again. It'll be great exam review and will help you to learn and understand better than trying to read someone else's code.
Post your code as you go along and if you get stuck and we'll try to help you out.
Last edited by Gox; 11-13-2008 at 09:51 AM..