Hi every one,
I am new student in
java programming, so I need your help
I want to takes a function as its input a
string of decimal integers, each character in the string can be thought of as a decimal digit. The digit should be converted to 3-bit binary string an packed into an
int.
I did the following code, but there is problem in convert 5 and 6 also I want the output like this
1234567 = 001 010 011 100 101 110 111 class Bin
{
public static void main(String []args)
{
String N=(args[0]);
for(int i=0;i<N.length();i++)
{
String n=N.substring(i,i+1);
int a=Integer.parseInt(n);
int y=1,b;
String z="";
for(a=a;a!=0 ; )
{
z=z+y;
y=a&1;
a=a>>1;
}
b=Integer.parseInt(z);
System.out.print(" "+b+" ");
}
System.out.println();
}
}
Thanks,
[ September 30, 2004: Message edited by: Sultan A. A ]