Minakshi, welcome to JavaRanch.
I deleted your solution, because on JavaRanch we have a policy that we want to encourage people to learn - giving people complete solutions to their programming assignments does not help people learn. So, thank you for your contribution, but please don't post complete solutions. (And a tip:
UseCodeTags when you post source code).