Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The hex 2 Dec ( String hexString ) method, which comverts a hex string into a decimal number. Re - implement the hex 2 Dec

The hex2Dec(String hexString) method, which comverts a hex string into a decimal number.
Re-implement the hex2Dec 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 qQ.
package exceptions:
inport java.utit.5canner;
public class ToDecinal.
i
public static int bexfodeciaal(String hex)
i
int decinalvalue =0;
for (int i=0;i hex. length(); i++)
1
char hexchar = hex.charat(1):
decinalValue = decinalValue *16+ hexCharToDecinol(hexChar):
}
l
return decinalvalue;
public static int hex(harTobecinallchar ch)
f
return 10+ch-?'A' :
else // ch is '','1',..., or "9'
return ch-';
}
public static void adin(5tringlt args)
i
Scanner input = new Scanner(
Systen.in
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago