Question

3. (Binary to decimal)Write a method that converts binary numbers to decimal numbers. Use

the following headers: (25 points)

public static int binaryToDecimal(int binary)

Write a test program that prompts the user to enter binary numbers and display its corresponding

decimal numbers and implement codes to handle any incorrect input.

Note: please do not use general converting method.

Here is a sample run of the program:

Enter binary numbers: 1010101010

Decimal numbers: 682

Enter binary numbers: G1010

G1010 is an invalid input

Question image 1