Help me to find the mistake | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
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)); } }

31st Dec 2021, 3:29 PM
Achraf Soua
1 ответ
+ 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.
31st Dec 2021, 4:57 PM
A͢J
A͢J - avatar