Question: Program 1 (40 points) BinaryConversion.java Consider the following dialog: Enter a binary number: 1110 Conversion to decimal: 14 Enter a binary number: 10010000 Conversion to
Program 1 (40 points) BinaryConversion.java
Consider the following dialog:
Enter a binary number: 1110
Conversion to decimal: 14
Enter a binary number: 10010000
Conversion to decimal: 144
Enter a binary number: -1
All set !
Write the application implied above. In particular, the program will read a sequence of binary strings and convert each one to a decimal integer. The program will terminate when the string -1 is given. You must do the conversion by hand, and NOT use the predefined functions in Java for the wrapper class Integer.
You must use a function for the conversion to decimal, where the parameter to the function is the binary string, and the return value is the equivalent decimal integer.
public static int binaryToDecimal (String binaryString)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
