Your next step is to convert a "natural” (that is, whole and zero or positive)
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

Your next step is to convert a "natural” (that is, whole and zero or positive)

Part III: Convert from a natural hexaicosadecimal number to a double

Your next step is to convert a "natural” (that is, whole and zero or positive) hexaicosadecimal number to its equivalent decimal representation. (Where should this code go? Hint: You shouldn't create any more methods than you already have.) We'll start with just natural numbers for now to keep things simple, but eventually we'll be dealing with hexaicosadecimal numbers that are floating point – like floating.point - and/or negative – like-negative. 

The algorithm for doing this might look something like: 

accumulator = 0 for each character in the input String from left to right 

baseValue = the integer equivalent of the current character 

accumulator += baseValue * 26 length of the whole String –(index of the current character + 1)

return accumulator 

This is relatively straightforward using appropriate methods from the String class and the Math class, but computing "the integer equivalent of a character" can be a little bit tricky if you've never seen it before. 

One thing to note is that characters in Java use the Unicode standard, which in turn contains the ASCII standard (a table of ASCII characters can be found here:

https://www.cs.cmu.edu/~pattis/15-1XX/common/handouts/ascii.html) 

Another thing to note is that characters in Java are equivalent to their character code. (That is, char c = 'a'; is exactly the same as char c = 97.) 

A third thing to note is that the characters in ASCII are arranged in order. (That is, a = 97, b = 98, C = 99...Z = 122). 

A fourth thing to note is that while 'a' (97) and 'A' (65) have different character codes, you already know a convenient function that can ensure that your hexaicosadecimal string is all lowercase (or all uppercase, if you prefer), regardless of how it was typed in. 

If you take all these points together, you should be able to extract a single character from the 

input string and convert it to its equivalent hexaicosadecimal value (That is, a/A = 0, b/B = 1, c/C = 2, ... Z/Z = 25) simply. (By “simply" I mean one or two short lines of code; if you find yourself wanting to use more than this, perhaps go back to the drawing board.)

Hint
ComputerCoding: Coding is also called as the computer programming. It is how we communicate with computers. Code tells a computer what actions to take, and writing code is like creating a set of instructions. By learning to write code, you can tell computers what to do or how to behave in a much faster way....

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.