Welcome to coderanch. Before you post questions here, please ShowSomeEffort. We would like to know what you have tried and what is wrong with it. We can give solutions to errors in your program but cannot give away the source code. If this is your homework, please DoYourOwnHomework.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
--- Martin Fowler