0

Convertidor Binario

No.puedo resolver el código ayuda import java.util.Scanner; public Class Converter{ public static String toBinary (int num){ String binary=""; while(num > 0) { binary = (num%2)+binary; num /= 2; } return binary; } } 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)); }

30th Nov 2021, 5:55 AM
Gabriel Molina
Gabriel Molina - avatar
4 odpowiedzi
+ 2
Attempt?
30th Nov 2021, 6:01 AM
NEZ
NEZ - avatar
0
You wrote `Class` for defining the `Converter` class, it should be `class` not `Class` public class Converter // public Class Converter Class `Program` is missing a closing curly bracket of its body.
30th Nov 2021, 7:46 AM
Ipang
0
import java.util.Scanner; public class Converter { static String toBinary(int num){ String binary=""; while(num > 0) { binary = (num%2)+binary; num /= 2; } return binary; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); System.out.print(Converter.toBinary(x)); } }
30th Nov 2021, 2:10 PM
Gabriel Molina
Gabriel Molina - avatar