Question: Task Description: As a programmer, you want to create a java program that you can convert a binary string into a decimal and hexadecimal value.

Task Description: As a programmer, you want to create a java program that you can convert a binary string into a decimal and hexadecimal value. A binary string is a base 2 value of 0's and 1's (e.g.10010110001). A decimal value is a base 10 integer value of the binary string(e.g.1291). Finally, a hexadecimal value is which follows a base of 16(e.g.4B1). It should follow that a non-binary string cannot be converted from binary to decimal and hexadecimal values.
To get a decimal value, you add up all the binary digits of 1 times the power of 2 at their positions.
Example:
10110125+0+23+22+0+20=32+0+8+4+0+1
=45
To get a hexadecimal value, you split a binary string into groups of binary strings of size four starting from the right. If the binary string does not evenly split into groups of four, then Os should be added to the left of the binary string to until it can be split evenly. Then convert the individual strings to decimal values. If the decimal value is 10-15, then the hex value is A-F accordingly.
Example:
100101100010100101100010100=4;1011
=11;0001=14B1
After you have written the program in Notepad(windows), TextEdit(Mac), or text editors in Linux such as vim, emacs, or nano. Run the "javac" command (refer to the presentation if you do not remember) to create the java class files. Test if your java classes executes with the "java" command. Once you have successfully completed your program create an executable jar file. To accomplish this use the following command in the console:
jar -cvfe BinaryConverter.jar Main *.class Where BinaryConverter.jar is the name of jar file and Main is the name of the class containing main(String[] args).
 Task Description: As a programmer, you want to create a java

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!