COW Q2 N2 Binary & Hexadecimal Complete the following methods

advertisement
COW Q2 N2
Binary & Hexadecimal
Complete the following methods in the BinaryFun Class.
Level 1
Name:
displayBinaryArray
Input:
boolean [] binaryValues, Graphics g, int x, int y
Output:
nothing
Action:
draws the corresponding binary number to the screen at location x, y. Each true
represents a one and each false represents a 0. The variable at index 0 is the first digit in the
binary number and the last is the most significant digit. So
boolean [] binary values = {false, false, true, false, true};
would translate to
10100
Level 2
Name:
Input:
Output:
Action:
convertBinaryToDecimal
boolean [] binaryValues
int number
converts a binary number to a decimal number
Level 3
Name:
addBinary
Input:
boolean [] binaryOne, boolean [] binaryTwo
Output:
boolean [] binarySum
Action:
adds the binary values in binaryOne and binaryTwo and returns the sum in binarySum.
You may assume that binaryOne and binaryTwo are the same length. You should make
binarySum one digit longer.
Name:
Input:
Output:
Action:
Level 4
convertBinaryToHex
boolean [] binary
String hex;
converts a binary number to a hexadecimal String.
Level 5
Name:
Input:
Output:
Action:
convertDecimalToBinary
int decNumber
boolean [] binaryValues
converts a decimal number to a binary number
Download