Welcome to JavaRanch, Imaya Munusamy
You are on the right lines, but I think Sam wants division by 10, not 9.
We have a policy of not simply giving answers to that sort of question, but hints, and I think your post provides a very good hint for Sam Benry to work from.
Please don't post a refinement of that method, Imaya, but Sam, please use that as a start and work out what you are going to do. You will remember it a lot better after working it out for yourself.