M
mmoski
I'm writing a program that is supposed to read in any number of hex
values (3c 4a 5b 45 ect), convert them to binary (in this case
111100100101010110111000101). The program then counts the number of
ones in the sequence. Also, it is to figure out the longest sequence
of 0's and of 1's seperately. I have managed to make it as far as to
count all the ones, but the System.out.println(totalOnes); only works
if it's in one of the while loops! I am only supposed to output this
number once. But even test strings (System.out.println("Works")
don't run outside of those loops. What am I doing wrong?
values (3c 4a 5b 45 ect), convert them to binary (in this case
111100100101010110111000101). The program then counts the number of
ones in the sequence. Also, it is to figure out the longest sequence
of 0's and of 1's seperately. I have managed to make it as far as to
count all the ones, but the System.out.println(totalOnes); only works
if it's in one of the while loops! I am only supposed to output this
number once. But even test strings (System.out.println("Works")
don't run outside of those loops. What am I doing wrong?