0
Please can someone help me with the error Binary converter
import java.util.Scanner; //your code goes here public class Converter{ static int toBinary (){ String binary=""; while (num>0){ binary = (num%2)+binary; num /=2; return num; } } } public class Program { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); System.out.print(Converter.toBinary(x)); } }
1 Respuesta
+ 3
you are passing one argument x to toBinary method but but you don't have that method. You have empty argument toBinary() .
Error 1 : argument mismatch.
Return causes comes out of function immediately so your loop runs only one iteration.
Add return out of loop...
Depends on your next step, may you need some other changes...
Hope it helps...