Sounds straightforward enough. What have you got so far and where are you stuck?

Yes, I could write the code to do it, but you would learn nothing that way.