Hey Im having trouble on a homework assignment. I'm a noob at java. This is a part of a program that checks your binary number and returns true or false if its correct.
So I can't get the binCheck =+ k part to work. I want it to only add k to binCheck if the character is a 1, but it seems to do it regardless of the number.
I really need help.
public static boolean checkBin(String bin, int number)
// Sums up binary sequence
int numCheck = 0;
int m = 0;
for(int k = 128; k>=1 && m <= 8; k/=2)
if (bin.charAt(m) == '1');
numCheck += k;
if (numCheck == number)