Show us what you have done so far.
Akash singh Ranawat wrote:I have been trying to find a code...
This is not a good thing to do.
You should try to build the logic (may be using pen-paper) and write the code instead of "trying to find the code" on internet.
Anyway everyone here will be happy to help once you post something which you have done and tell the problems you are facing.