Question: Java /** * Convert a char into a 16 bits array. * @param c the char to print * @return a boolean array of length

Java

/** * Convert a char into a 16 bits array. * @param c the char to print * @return a boolean array of length 16 representing the bit presentation of the character */ static boolean[] char2bitArray(char c) { }

/** * Convert a 16 bits array into a char. * @param arr a boolean array of length 16 representing a bit array * @return the character denoted by the bit array */ static char bitArray2char(boolean[] arr) { int character = 0, count = arr.length - 1; for(boolean x : arr){ if(x == true) {character += Math.pow(2,count);} count--; } return (char)character; }

/** * Test the previous two coding functions by converting the text into an array of characters. * Then for each character, it converts it into a bit array and * then converts the bit array back into a character. * Finally, the program constructs a new String given an array of all the generated characters. * Print the text before and after the transformations. * @param text an input string to test */ static void testCoding(String text) { }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!