Home Answers Viewqa Java-Beginners in string how will write the return statement..........?

 
 


Aare.SandeepReddy
in string how will write the return statement..........?
0 Answer(s)      4 months and 15 days ago
Posted in : Java Beginners

import java.util.Scanner;
class BinaryConversion12{
 static int  j=1;
 static int l=1;
 public static void main(String args[]){
int i=Integer.parseInt(args[0]);
if(i>=256){
    System.out.println("please enter decimal no should be lessthan 256");
}
else{
    binary(i);
}
}
public static String binary(int i){
    if(i!=0)
    {
        int temp=0;
        temp=i%2;
        i=i/2;
        j++;
        binary(i);
        if(j==8)
            System.out.println(temp);
        else{
            l++;
            for(int k=j; k<=8; k++)
                if(l==2){
                System.out.print("0");
            }
            System.out.print(temp);
        }
    }
}
}
View Answers









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.