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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started