Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Have Programming Question? Ask it here!
 
 
 


Aare.SandeepReddy
in string how will write the return statement..........?
0 Answer(s)      a year and 8 months 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);
        }
    }
}
}

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Advertisements
Advertisements
 

 

 

DMCA.com