- 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
7 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
+ 1
Is this your full code ?
Naveen Narayani .S
0
Post your code
0
show the code and we will help you ?
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));
}
}
- 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));
}
}