Write a Program that accepts a decimal number n, and converts the number to binary.
The return type is long representing the binary number.
Input and Output Format:
Input consists of the single integer.
The output consists of a single long.
Refer sample output for formatting specifications.
Sample Input 1:
5
Sample Output 1:
101
Convert decimal to binary conversion in Java.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String s1=Integer.toBinaryString(n);
long y=Long.parseLong(s1);
System.out.println(y);
}
}