Here's my code:
import java.util.*;
public class binary{
public static void main(String args[])
{
//input thing
Scanner read = new Scanner(System.in);
//variables
String result = "";
int input;
//input
input =read.nextInt();
toBinary(input,result);
System.out.println("Your binary is" + result);
}
public static String toBinary(int a,String b){
StringBuilder sb = new StringBuilder();
int y;
int z=2;
while(a >= 1){
y = a%2;
a/=z;
sb.append(y);
}
b = sb.toString();
invert(b);
return b;
}
public static String invert(String s) {
String temp = "";
for (int i = s.length() - 1; i >= 0; i--)
temp += s.charAt(i);
return temp;
}
}
Can you help me on whats wrong, cause the return is blank. When I type in a number it comes out as nothing execpt "Your binary is".