A program-problem related to JAVA.......... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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
BlackSpadesZ7
BlackSpadesZ7 - avatar
3 Answers
+ 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
Please use relevant tags ā˜ https://code.sololearn.com/W3uiji9X28C1/?ref=app
1st Feb 2022, 1:22 PM
Ipang