Hi Bhupathi,
Welcome to the Cattle Drive forum!
I think it's safe to say that many
Java students are given this problem to solve. So if you
search the web you will find enough examples of code which will give you things to try out and give you a start on your own solution.
You could also search this forum (The 4th assignment of the Cattle Drive (Java-4a and -4b) is concerned mainly with this conversion) but you won't find any code here as that would be giving the solutions away, which is not the idea
.