how could i rewrite this code in binary to decimal

For converting from the binary to decimal you have to use scintific calculator.But if you want to do paper work then it is difficult to explain here all the method.So you need to study all the stuff about the converting the numbers.

Regards.
Andy.

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

Make use of what Java already offers you: Click Here
You can use the method Integer.parseInt(string containing the number in some base, base) method, but pay attention as digits from the string must be included in the radix of the 2nd argument. For example, if you want to parse the string "234122" and the radix is set to 3 you'll get a NumberFormatException exception.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.