The problem in your code is that your if-statements closes to early:
if (binary.charAt(binary.length()-i-1) == '0');
ten += 0;
should be
if (binary.charAt(binary.length()-i-1) == '0'){
ten += 0;
}
There are, of course, some other things that could be done differently, but you'll figure that out along the way.