Here is the solution:

For each string of bits, perform the following:

Create an array of 256 chars, the value of each element is the ASCII value of the index. For example, the value of element 65 is the character ‘A’. This is the translationTable referenced below.

If the length of the string of bits is divisible by 8, continue.

If the string of bits contains only digits 0 and 1, continue.

Split the string of bits into smaller strings, each of which is exactly 8 digits in length.

For each 8-bit string, convert from binary to decimal.

Using the translationTable, convert from decimal to the desired ASCII character.

Accumulate the individual characters into a string (perhaps using a StringBuilder).

public class Scratchpad extends ConsoleProgram

{

public String binaryToText(String binary)

{

String s2 = “”;

char nextChar;

for(int i = 0; i <= binary.length()-8; i += 8) { nextChar = (char)Integer.parseInt(binary.substring(i, i+8), 2); s2 += nextChar; } return s2; public int binaryToDecimal(String binaryString) { int numPlaces = binaryString.length(); int currentExponent = numPlaces - 1; int decimalValue = 0; for(int i = 0; i < binaryString.length(); i++) { int placeValue = (int) Math.pow(2, currentExponent); char currentDigit = binaryString.charAt(i); int digitValue = Character.getNumericValue(currentDigit); System.out.print(digitValue + " * (" + placeValue + ")"); if(i != binaryString.length() - 1) { System.out.print(" + "); } decimalValue += digitValue * placeValue; currentExponent--; } System.out.println(" = " + decimalValue); return decimalValue; } }