Sounds straight forward enough. How far have you got, and where are you stuck?
If you post code, please use [ code ] and [ /code ] tags (without spaces) so that the code formatting is preserved.
Your course should have covered how to start writing code and some of the data structures necessary to solve this; it would be a very poor course where they said "welcome to the Java programming course, here's your first task and now I'm off for a coffee".