title: How to convert from any base to base 10 in Java
body: <p>i'm new at Java. I want to write a program that converts from base 2, 3, 4, 5, 6, 7, 8, 9, 16 to base 10 using only aritmetic operations. </p>
  
  <p>I've done with reading a string from keyboard (in case if number is in hexadecimal) and converting it to an integer, after this i made a while loop what split number to digits and inverts them. </p>
  
  <p>Now i don't know how to make this digits to multiply with 2 at power 0, 1, 2, etc.(in binary case) to convert the number to base 10. </p>
  
  <p>For example 1001 (number 9 in decimal) it's like 1x2(pow 0)+0x2(pow 1)+0x2(pow 2)+1x2(pow 3). </p>
  
  <p>My code:</p>
  
  <pre><code>public static void main(String[] args) throws IOException {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      System.out.println("Introduceti din ce baza doriti sa convertiti numarul: 2, 3, 4, 5, 6, 7, 8, 9, 16 ");
      int n = Integer.parseInt(br.readLine());
      Scanner scanner = new Scanner(System.in);
      System.out.println("Introduceti numarul care doriti sa fie convertit din baza aleasa ");
      String inputString = scanner.nextLine();
      if (n==2){
          int conv = Integer.parseInt(inputString);
          while (conv&gt;0){
              System.out.println (conv%10);
              conv = conv/10;        
          }
      }
  }
  </code></pre>