(Number Format Exception)Write the bin2Dec(String binary String) method to convert a binary string into a decimal number. Implement the bin2Dec method to throw a Number Format Exception if the string...

(Number Format Exception)Write the bin2Dec(String binary String) method to convert a binary string into a decimal number. Implement the bin2Dec method to throw a Number Format Exception if the string is not a binary string. Write a test program that prompts the user to enter a binary number as a string and displays decimal equivalent of the string. If the method throws an exception, display "Not a binary number".



Sample Run 1


Enter a binary number: 101


5



Sample Run 2


Enter a binary number: 41


Not a binary number: 41





May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here