Lab6: Week of Feb 09-15
 


US Postal service encourages users to print bar code denoting the 5 digit ZIP code (similar to 6 digit PIN in India). An example of how bar codes look can be found on http://pe.usps.gov/text/pub25/Pub25ch4.htm

Basically each number is represented by a sequence of five full height and half height bars. Each digit of the ZIP code is encoded using following table:

Digit coding
1       00011
2 00101
3 00110
4 01001
5 01010
6 01100
7 10001
8 10010
9 10100
0 11000

Where 0 denotes a half bar and 1 denotes a full bar. We can represent a full bar by character | and a half bar by character : Therefore digit 9 will be represented as |:|::

There is an additional digit called check digit which is computed as follows: add five digits and then choose the correction digit to make the sum a multiple of 10. For example ZIP code 95014 has sum of digits 19, so the correction digit is 1 to make the sum equal to 20.

The full bar code has 32 bars which correspond to:
Frame bar: a full height bar
Twenty five bars: full and half corresponding to 5 digit ZIP code
Five bars: corresponding to the check digit
Frame bar: a full height bar

Write a program that asks for user ZIP code and prints the bar code. For example 95014 becomes:
||:|:::|:|:||::::::||:|::|:::|||

Note: You will get extra credit if you can generate output as actual bar codes.