Question: The hex 2 Dec ( String hexString ) method, which comverts a hex string into a decimal number. Re - implement the hex 2 Dec
The hexDecString hexString method, which comverts a hex string into a decimal number.
Reimplement the hexDec method to throw a NumberformatException if the string is not a
hex string. Catch the exception inside the while loop of main and stay in the program until the
user types
package exceptions:
inport java.utitcanner;
public class ToDecinal.
i
public static int bexfodeciaalString hex
i
int decinalvalue ;
for int ; hex. length; i
char hexchar hex.charat:
decinalValue decinalValue hexCharToDecinolhexChar:
l
return decinalvalue;
public static int hexharTobecinallchar ch
f
return :
else ch is or
return ;
public static void adintringlt args
i
Scanner input new Scanner
Systen.in
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
