Question: Create a Java Program A binary number system represents each integer with only 0 ' s and 1 ' s . This is how information

Create a Java Program
A binary number system represents each integer with only 0's and 1's. This is how information is
stored in a computer. For example, the number 9 is stored as 1001 and the number 12 is stored as
In this problem, you will be converting a 4-digits binary number into an integer we normally
use. The conversion process is given below:
Let the binary number (declared as int) be stored in a variable called binary and the result of
conversion is stored in a variable result (declared as int). Initialize result to 0.
Get binary %10 and add it to result.
Get binary /10 and store it in a variable called temporary1(declared as int).
Get temporary 1%10, multiply it by 2 and add it to result.
Get temporary1/10 and store it in a variable called temporary2(declared as int).
Get temporary 2%10, multiply it by 4 and add it to result.
Get temporary2/10 and store it in a variable called temporary3(declared as int).
Get temporary 3%10, multiply by 8 and add it to result.
The variable result now should have the converted value.
Programming requirements
You should read binary from input. Make sure that you only input a 4-digit number and it
contains only 0's and 1's.
You should print both binary and result with appropriate captions at the end.
To cross-check your answers, the following table shows all 4-digits binary numbers and their corre-
sponding converted integers.
Cre
 Create a Java Program A binary number system represents each integer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!