Write a recursive method that parses a positive binary number as a string into a decimal integer.
//Assume the input is always digit only. //If the input is not a binary number, return the same number in the integer format Sample Input1
//A binary input 11 Sample Output1 3 Sample Input2 //Not a binary input 00112 Sample Output2 112
import java.util.*;import java.lang.*;import java.io.*;
class BinaryToDecimal{
// You can add more methods
public static int binaryToDecimal(String binaryString){//write your code here}}class DriverMain{public static void main(String args[]){Scanner input = new Scanner(System.in);System.out.print(BinaryToDecimal.binaryToDecimal(input.nextLine()));}}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here