Quote:
What is the code for below problem?
It is whatever you want it to be; whatever your mind can come up with. There is no "the code" for any problem; they can all be solved in a multitude of ways. Lose the idea that there is "one solution" to any problem in development: there almost never is.
Having said that, we do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
Try it yourself, you may find it is not as difficult as you think!
If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!