title: How to convert a binary String to a decimal string in Java
body: <p>I was working on a homework and thought I had finished but the teacher told me that it wasn't what he was looking for so I need to know how I can convert a binary number that is stored as a String to a decimal string without using any built-in function outside of length(), charAt(), power function, and floor/ceiling in Java.</p>
  
  <p>This is what I had on the beginning.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class inclass2Fall15Second {
      public static void convertBinaryToDecimalString() {
          Scanner myscnr = new Scanner(System.in);
  
          int decimal = 0;
  
          String binary;
          System.out.println("Please enter a binary number: ");
          binary = myscnr.nextLine();
          decimal = Integer.parseInt(binary, 2);
          System.out.println("The decimal number that corresponds to " + binary + " is " + decimal);
      }
  
      public static void main (String[] args) {
          convertBinaryToDecimalString();
      }
  }
  </code></pre>