Do your own homework man. Posts that include "I need code that does this..." and "...I need it urgently" are often from students who think they can come to this forum and get their homework done by someone else, and that sound like your case.
People on this forum help anyone who needs it but we do not give away code just like that.