Yeah, way to go. You have the logic, and you're step behind from what you want to implement.
And no (a big no), we're not going to write anything for you. That's is something you need to do.
As I assume, this a homework; it won't entertained here.
If you expect us to do your homework, that's not going to work. There's a pretty good reason behind this: "You won't be learn anything, if you expect others do your work for you".
You can try something on your own at first and when you stuck anywhere, anyone from here would do his/her best to help you out. But
don't directly ask for the source code.
Thanks to
Richard [
^], please read this:
A link to the Guidelines
[
^]
-KR