Question
Implement a Java method named parseHex() that converts a String (consisting of digits and uppercase letters ONLY ; for now, dont worry about lowercase letters
Implement a Java method named parseHex() that converts a String (consisting of digits and uppercase letters ONLY; for now, dont worry about lowercase letters or other characters) from hexadecimal (base 16) to decimal (base 10) and returns the result as an integer. Define a custom HexFormatException class that extends Exception. Your method should throw a HexFormatException if the string is NOT a valid hexadecimal value (e.g., if it contains any uppercase letters outside the range AF).
As a reminder, one basic (pseudocode) algorithm for translating from base N to base 10 is as follows:
total 0 currentPower 1
for each digit/position in the base N value, working from right to left: total total + (current digits value * currentPower) currentPower currentPower * N
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