Question: Write a program (Java) that prompts the user for an 8 bit (a byte) binary number and converts that into a decimal number. For binary

Write a program (Java) that prompts the user for an 8 bit (a byte) binary number and converts that into a decimal number. For binary conversion, look at each of the digits values, multiplied by their position, and sum those together to get the resulting value.

Write a program (Java) that prompts the user for an 8 bit

Objective: Write a program that prompts the user for an 8 bit (a byte) binary number and converts that into a decimal number. For binary conversion, look at each of the digit's values, multiplied by theit position, and sum those together to get the resulting value. Let's take the byte 01011001 and convert it into a decimal value. Binary Digit 0 1 0 1 1 0 0 1 Base 2 Representation 27 26 25 24 23 22 21 20 at this position Decimal Value 1 128 64 32 16 I 8 4 at this position 2 1 Multiplying each binary digit by the decimal values and summing them you get 0*128+1*64+0*32+1*16+1*8+0*4+0+2+1*1 = 89 Assume the user will only input either 0 or 1 without having the check. Also built in Java methods that does this conversion automatically (such as Integer.parseInt(String.2)) WILL NOT be accepted. However, you may still use Integer.parseInt(String) to convert from a String to an integer. Example Dialog: Enter an 8 bit binary number and I will convert it to decimal 01011001 01011001 in decimal form is 89 Finally: Upload the java file to the dropbox

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!