okay ill explain.this is a program that will convert binary.

import java.io.*;
public class decbin{
public static DataStreamReader rustan=new DataStreamReader(System.in)
public static void main (string[]args) throws IOException{
int Q,R,A;
System.out.println("Enter a number to be convert: ");
Q=Integer.parseInt(rustan.readLine());




while(Q!=0){
Q=A/2;
R=A%2;
A=Q;
//one missing statement i think. i need help.
}

or you have anyway???pls help

The while statement is correct. You don't need the A; it is in the Q where you store your input and that's what you want to modify. If you look your code you will see that you write Q=A/2 without giving any values to A in the first place.
You should write something like:

R=Q%2;
Q=Q/2;

If you write the Q=Q/2 first, and then the R=Q%2, then the R will not have the correct value because the Q would have been altered and then you would try to get the modulus of the wrong Q.
Then you must store the R in a String value using the concat operator "+" inside the while loop, because you calculate a new R each time and you don't save it anywhere:

Outside the loop: String result="";

Inside the loop you must have one of these two:

result=result+R;

or

result=R+result;

You must decide which one is correct

what's he trying to do anyway?
Just use NumberFormat and supply a base of 2 for the output format :)

Correct me If I am wrong but I have a feeling jwenting, that he is supposed to use the specific algorithm for calculating the binary number. I think it was meant for homework but I don't know for sure

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.