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)); } }

4th Jul 2022, 2:06 PM
MR KINGSHOW
MR KINGSHOW - avatar
1 Odpowiedź
+ 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...
4th Jul 2022, 2:18 PM
Jayakrishna 🇮🇳