When you say you want "the code" -- are you talking COBOL? SAS? JAVA? PL/I? ASSEMBLER? FORTRAN? REXX? CLIST? Something else entirely?
Finally, this is a HELP forum, not a DO-YOUR-JOB-FOR-YOU forum. We can help you with coding problems, but we don't provide code unless you are willing to pay the going daily rate for professional consulting (typically about 1000 U.S. dollars per day).
Google is your friend. What you are looking for is called "Zeller's Congruence" and Googling zeller's congruence returns 13,700 hits and several on the first page will give you the exact formula to use. It is easily implemented in COBOL or any other procedural language.