Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program to convert a string corresponding to a hexadecimal number of the form 0xHHHHHH to decimal as shown in the following examples:

Write a Java program to convert a string corresponding to a hexadecimal number of the form 0xHHHHHH to decimal as shown in the following examples:
Hexadecimal conversion program
Enter a hex number in the format 0xH...H, +ve only, blank line terminates.
Input is case insensitive except for leading 0x
> 0xFf
0xFf = 255
> 0
0 is not a valid entry.
> 0x0
0x0 = 0
> 0x10
0x10 = 16
> 0xf
0xf = 15
> 0xF
0xF = 15
> 0xfFfF
0xfFfF = 65535
>
Program terminated.
Notes
1. The input string must begin with the prefix 0x.
2. The hexadecimal digits are case insensitive, i.e., f and F are both interpreted as 15.
3. Your program MUST replicate the above example, EXACTLY.
4. Your program will consist of a single class, HexConversion, and must implement a method, hex2Int() with the following signature:
int hex2Int (String input);
5. This program is similar to Assignment 1. Of the String class methods, you are only allowed to use equals(), length(), charAt() and startsWith().

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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions