In this section, you will learn to convert a number to a binary (0,1). The given number is a decimal format and the following program to calculate its binary.
This program takes a decimal number at the console. This number is as a string format so, it must be converted into an integer type data using the Integer.parseInt() method. The toBinaryString() method is used for converting an integer type data into a binary.
Here is the code of this program:
Output of this program given below.
Enter any number:
Binary number is:11001
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: July 5, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles