@@ -0,0 +1,950 @@
+import java.util.Scanner;%0Aimport java.lang.*;%0A%0Apublic class binary_decimal_converter %7B%0A%09public static void main(String%5B%5D args) %7B%0A%09%09//directions%0A%09%09Scanner s = new Scanner(System.in);%0A%09%09System.out.println(%22Enter the number of digits in your binary number%22);%0A%09%09int digits = s.nextInt();%0A%09%09System.out.println(%22Enter the binary you wish to convert to decimal%22);%0A%0A%09%09// gather input into array%0A%09%09int%5B%5D binary = new int%5Bdigits%5D;%0A%09%09for(int i = 0; i %3C digits; i++) %7B%0A%09%09%09int input = s.nextInt();%0A%09%09%09if(input %3E 1) %7B%0A%09%09%09%09System.out.println(%22Error - incorrect binary input%22);%0A%09%09%09%09System.exit(1);%0A%09%09%09%7D else %7B%0A%09%09%09%09binary%5Bi%5D = input;%0A%09%09%09%7D%0A%09%09%7D %0A%0A%09%09//calculate%0A%09%09int decimal = 0;%0A%09%09for(int i = 0; i %3C digits; i++) %7B%0A%09%09%09decimal += binary%5Bi%5D * Math.pow(2, i);%0A%09%09%7D%0A%0A%09%09//print result%0A%09%09System.out.println(%22The decimal value of %22);%0A %09%09for(int j = 0; j %3C digits; j++) %7B%0A%09            System.out.printf(%22%25d%22, binary%5Bj%5D);%0A%09        %7D%0A%09%09System.out.println(%22 is %22 + decimal);%0A%09%7D%0A%7D%0A

converts binary to decimal