68 379
Assignments Done
98,5%
Successfully Done
In November 2018

Answer to Question #40180 in Java | JSP | JSF for LostWind

Question #40180
Write a recursive method that converts a decimal integer to a binary string.
Expert's answer
public class IntegerToStringBinary {

public static void main(String argv[]){
int num = 105; //enter your integer number here
System.out.println(convertToBinary(num));
}

public static String convertToBinary(int number)
{
if(number > 0)
{
String str1 = new String(convertToBinary(number / 2));
String str2 = new String(str1+Integer.toString(number % 2));
return str2;
}

return "0";
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions