This content has been marked as final. Show 3 replies
I presume that your real question is that you want to issue a bar code using a specification that includes alphas.
Since barcodes have their own representation you need to map it.
An efficient way to do that is a int array.
Create an array that is 128 in size. That represents the ASCII character set. Each space in that character set will have one of the following values.
- Negative one, this indicates there is no mapped value.
- The binary representation of a bar code number
(The above is based on a single barcode specification that I found which would allow mapping bits to a barcodes.)
Then for each character in an input you use the array to either get the barcode value or report that the character is not allowed (or perhaps just remove it.)
Fenhoff wrote:Easiest way is to use Integer.parseInt(String) or Double.parseDouble(String)
Was wondering how to convert letters to numbers in java. We are working on a problem in class that has you input
if you just have a char, you could try
char ch = ...;
int val = ch - '1' + 1;
I'm not sure all the numbers (especially 0) are lined up the right way though.