This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
As people have said, you will have to show what you have done so far. By the way, for code you should always use code tags. They work for what you posted, too; you can see the spaces appear in the right places now I have added the tags.
If you read the links that Bear posted, and also the ShowSomeEffort(←click) link, you'll see that folks here aren't going to just hand you the answer. So take your best shot, and come back with specific questions if you get stuck.
Here's a very important tip though: Don't write a single line of code until you've written down very clear, precise, simple steps in English (or whatever your native language may be) describing how to do the process without regard to any programming language.