Hi all I am trying to write an encryption program which converts each letter of the input to a 7 byte binary number before outputting. I am using the .toBinaryString method for this so please do not suggest another solution, the problem I am having is that it only converts the first character of the string! any help is appreciated here is my attempt
public static void convert(String h)
{
int y =0;
String f =" ";
for(int i =0; i<h.length(); i++)
{
y = (int)h.charAt(i);
f = Integer.toBinaryString(y);
}
System.out.println(y);
System.out.println(f);
}
I print out y,f to see is it successfully converts it. It works when I input a single character but when I input eg ben it will convert the whole string not letter by letter!