0
Help me to find the mistake
import java.util.Scanner; public class Converter { //your code goes here public static String toBinary() ; Converter (){ String binary=""; while(num > 0) { binary = (num%2)+binary; num /= 2; } } } 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 Answer
+ 4
Achraf Soua
toBinary() method should have an argument type of int
Remove semicolon (;) after method definition
And what is Converter() here?
Also you should return binary because your method has String return type.