Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions