- 2

Write a Binary covert program in java. Use optimize techniques

Any binary convert (ex). Binary to hexa decimal binary to octal. Octal to binary

28th May 2021, 6:19 AM
Naveen Narayani .S
Naveen Narayani .S - avatar
6 Answers
+ 4
Naveen Narayani .S public class Program {public static void main(String[] args) { int a=73; System.out.println(Integer.toBinaryString(a));}} //Do like this
28th May 2021, 11:46 AM
Atul [Inactive]
+ 1
Is this your full code ? Naveen Narayani .S
28th May 2021, 9:13 AM
Atul [Inactive]
0
Post your code
28th May 2021, 7:22 AM
Atul [Inactive]
0
show the code and we will help you ?
28th May 2021, 7:24 AM
JRAMAHES
JRAMAHES - avatar
0
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)); } }
28th May 2021, 9:15 AM
Naveen Narayani .S
Naveen Narayani .S - avatar
- 1
import java.util.Scanner; 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)); } }
28th May 2021, 8:47 AM
Naveen Narayani .S
Naveen Narayani .S - avatar