It's a quite simple program.

Before spoon-feeding the solution, can you tell us how much have you progressed ?
[ Try yourself first, before asking for ready-made solutions. That way you'll be benefited ]