public static int toDecimal(String binaryNumber) { //write your code here if(binaryNumber==null || binaryNumber.isEmpty()) { return 0; } int decNo=0; int temp=Integer.valueOf(binaryNumber); for(int i=0;i<binaryNumber.length();i++) { int n=temp%10; decNo=(int) (decNo+(n*(Math.pow(2, i)))); temp=temp/10; } return decNo; }