Have the function BinaryConverter(str) return the decimal form of the binary value.
For example: if 101 is passed return 5, or if 1000 is passed return 8.
Binary Converter Solution in java
import java.util.Scanner;
public class BinaryConverter {
int BinaryConverter(String str) {
return Integer.parseInt(str, 2);
}
public static void main (String[] args) {
// keep this function call here
Scanner s = new Scanner(System.in);
BinaryConverter c = new BinaryConverter();
System.out.print(c.BinaryConverter(s.nextLine()));
}
}
Binary Converter Solution in Python
def BinaryConverter(str):
return int(str, 2)
# keep this function call here
# to see how to enter arguments in Python scroll down
print BinaryConverter(raw_input())