Hd Desai wrote:But this program is failing.
just as a tip for next time...just saying "my program doesn't work" is really pointless. There are thousands of ways it could "not work". One of three things should be happening:
1) You get a compiler error. If so, tell us the EXACT text of that error. There is a LOT of info there, once you learn how to read it
2) Your program crashes when it runs. Again, you'll get some kind of message telling you what went wrong.
3) Your program runs, but behaves differently than you expect. We don't know what you expect, nor do we know what it does do. You need to tell us both.
You will find you generally get much more help, better help, and quicker help, if you do the above.