Did you even try to do it yourself? I'm not against borrowing code to get the job done, but this is clearly homework, and homework is meant to be solved so that you can learn to be a better programmer.
what help is this forum if nobody can help, im asking for help and you sending me somewhere else. So what if its homework, ive already tried starting it, i just need a working version to see what i was doing wrong.
>what help is this forum if nobody can help
It's not that nobody can help, it's that nobody chooses to help when you haven't shown us what you've tried. You simply asked for code or a link to code, which is frowned upon in this forum.
>ive already tried starting it
So post your code and we'll help you fix the problems.
>i just need a working version to see what i was doing wrong.
Too many people try to trick us into doing their homework for them. I don't believe you're doing that, but if I make an exception for you then it'll set a bad example. I'm truly sorry, but you need to show us what you've already tried before we can help in any meaningful way.