This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Is this a homework question? JavaRanch is not a code mill.
So, what have you tried yourself and where do you get stuck? With assignments like these, it helps to first think about the problem itself - describe in normal language how you would solve this. When you're clear about how you're going to do it, you can start thinking about writing Java code.