Question: Write a program that user enters 4 position hexadecimal number and you output the decimal value along with hexadecimal value. Thus 4A7C would output Hexadecimal=4A7C

Write a program that user enters 4 position hexadecimal number and you output the decimal value along with hexadecimal value. Thus 4A7C would output

Hexadecimal=4A7C equals decimal 19068. You can NOT use any Java commands that convert text to numbers.

Pseudocode:

input 4 digit hexadecimal number as string

get each character at each position and calculate decimal number

4 A 7 C

4 * 163 + 10*162 + 7*161 + 12* 160

4=charAt(0) 10= charAt(1) 7= charAt(2) 12=charAt(3)

HINT: Math.pow(16,indexK) is the same as 16indexK

output input string as well as decimal value -- see example above.

EXTRA CREDIT MAKE PROGRAM READ IN HEXADECIMAL NUMBER ANY LENGTH

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!