That sounds like an assignment. That means YOU write it, not us. Go over, in your mind, what you have been taught (you did pay attention in class, right?) and write some code expressing that. We will be glad to help you debug it, or give you a few pointers, or whatever.