QUESTION 4
Write a method convert () to compute and print the decimal equivalent of the following binary
numbers. 10, 110, 1101, 1010, 11110. [15]
Answers
Answered by
0
Explanation:
128 + 0 + 0 + 16 + 0 + 4 + 2 + 0 = 150. This is the decimal equivalent of the binary number 10010110.
Answered by
1
static void convert( ) {
String[ ] numbers = {"10", "110", "1101", "1010", "11110"};
for (String binary : numbers)
System.out.printf("%s - %d%n", binary, Integer.parseInt(binary, 2));
}
Similar questions