This is a Java Program to Convert Integer Values into Binary.
Enter any decimal number as an input. After that we operatons like modulo and division to convert the gven input into binary number.
Here is the source code of the Java Program to Convert Integer Values into Binary. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
import java.util.Scanner;
public class Decimal_Binary
{
public static void main(String[] args)
{
int n, m;
String x = “”;
Scanner s = new Scanner(System.in);
System.out.print(“Enter the Decimal Number:”);
n = s.nextInt();
while(n > 0)
{
int a = n % 2;
x = a + x;
n = n / 2;
}
System.out.println(x);
}
}
Output:
$ javac Decimal_Binary.java
$ java Decimal_Binary
Enter the Decimal Number:19
10011