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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started