We're not going to write your program for you. We're not going to solve all of your problems. This problem, in particular, is ridiculously easy to solve. Part of programming is thinking. Try it. Another part (a big part) is RTFM. Failing that, STFW. Since you've already failed at all of those parts (apparently) try reading everything here.