DECIMAL TO BINARY IN JAVA USING BITWISE. anyone can guide me?

i have a problem with my program in java
there are one error in my code and i dont know how to correct it
pls help me. tnx a lot !
heres my code.

package exer1;
import java.util.Scanner;
/**
*
* @author Owner
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args){
int max[] = new int[8];
Scanner scan = new Scanner(System.in);
String bin;
int dec;
int y = 0;
int man;
System.out.println("pls type a no. [1-127]: ");
bin = scan.next();
dec = Integer.parseInt(bin);

int num;

for(int x=0;x<=8;x++){
man = num &1;
num=num>>1;
{
System.out.print(max[x]);
}
System.out.print("The binary equivalent is " );
for (int z=y; z>0; z--)
{
System.out.print(max[z]);
}

int a=1;
while (a==1)
{
System.out.println("\n" + "Enter 1 for enter another value or 0 to exit:");
String reply=scan.next();
int b=Integer.parseInt(reply);
if(b==1)
a=1;
else
a=0;
}
}
}
}
how do you expect it to work?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
for(int x=0;x<=8;x++){
   man = num &1;//man is never used
   num=num>>1;
   {//why?
   System.out.print(max[x]); //max[x] is never initialized (except by new)
   }
   System.out.print("The binary equivalent is " ); 
   for (int z=y; z>0; z--) { //y = 0. what was it supposed to be?
      System.out.print(max[z]);
   } 

   int a=1; 
   while (a==1){//this loop is not where it should be and doesn't do what you want it to do
      System.out.println("\n" + "Enter 1 for enter another value or 0 to exit:"); 
      String reply=scan.next(); 
      int b=Integer.parseInt(reply); 
      if(b==1) a=1; 
      else a=0;
   }
}

by the way, this is a c++ forum..
Hi

Site name is http://www.cplusplus.com/
Topic archived. No new replies allowed.