Looks like a homework assignment and don't you think you need to be doing it yourself. Yes we can help you in debugging it.