+ 2

A program-problem related to JAVA..........

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

1st Feb 2022, 11:16 AM
Tripti Tiwari
Tripti Tiwari - avatar
3 ответов
+ 2
import java.util.Scanner; public class Converter { public static String toBinary(int num){ //here String binary=""; while(num>0) { binary =(num%2)+binary; num/=2; } return binary; }//here } public class Program { public static void main(String[]args){//here Scanner sc=new Scanner(System.in); int x=sc.nextInt(); System.out.print(Converter.toBinary(x) ); }//here }
1st Feb 2022, 12:37 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 3
you are missing some { } toBinary(int num) { code here } main(String [] args) { }
1st Feb 2022, 11:58 AM
Bahhaⵣ
Bahhaⵣ - avatar
+ 2
1st Feb 2022, 1:22 PM
Ipang