in string how will write the return statement..........?
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 Tutorials/Questions & Answers:
Advertisements