|Problem number 1, you have not asked a question|
Problem number 2, you have not shown that you have attempted to do this yourself
problem number 3, this looks like homework. if you do not do your homework yourself how are you planning on learning anything?
Problem number 4, maybe if you read your books or got some help from your teacher, you will learn this for yourself and be able to do this yourself.
Give it a try, if you get stuck, show us your code and where you are having problems.