Java Reference
In-Depth Information
Figure 8
Encoding for Five-Digit Bar Codes
383
384
Each digit of the ZIP code, and the check digit, is encoded according to
the following table:
7
4
2
1
0
1
0
0
0
1
1
2
0
0
1
0
1
3
0
0
1
1
0
4
0
1
0
0
1
5
0
1
0
1
0
6
0
1
1
0
0
7
1
0
0
0
1
8
1
0
0
1
0
9
1
0
1
0
0
0
1
1
0
0
0
where
0
denotes a half bar and 1 a full bar. Note that they represent all
combinations of two full and three half bars. The digit can be computed
easily from the bar code using the column weights
7
,
4
,
2
,
1
,
0
. For
example,
01100
is
0.7 + 1.4 + 1.2 + 0.1 + 0.0 = 6
The only exception is
0
, which would yield 11 according to the weight
formula.
Write a program that asks the user for a ZIP code and prints the bar code.
Use : for half bars, | for full bars. For example, 95014 becomes
||:|:::|:|:||::::::||:|::|:::|||