Question: Postal bar codes C++ Program In c++ please For faster sorting of letters, the United States Postal Service encourages companies that send large volumes of

Postal bar codes C++ Program

In c++ please

For faster sorting of letters, the United States Postal Service encourages companies that send large volumes of mail to use a bar code denoting the zip code. (See Figure 1).

 Postal bar codes C++ Program In c++ please For faster sorting

Figure 1 A Postal Bar Code

The encoding scheme for a five-digit code is shown in Figure 2. There are full-height frame bars on each side. The five encoded digits are followed by a check digit, which is computed as follows: Add up all digits, and choose the check digit to make the sume a multiple of 10. For example, the zip code 95014 has a sum of 19, so the check digit is 1 to make the sum equal to 20.

of letters, the United States Postal Service encourages companies that send large

Figure 2 Encoding for Five-Digit Bar Codes

Each digit of the zip code, and the check digit, is encoded according to the following table where 0 denotes a half bar and 1 full bar.

Digit Bar 1 (weight 7 ) Bar 2 (weight 4 ) Bar 3 (weight 2 ) Bar 4 (weight 1 ) Bar 5 (weight 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

The digit can be easily computed from the bar code using the column weights 7, 4, 2, 1, 0. For example, 01100 is 0x7 +1x4+1x2+0x1+0x0 = 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

||:|:::|:|:||::::::||:|::|:::|||

Also the program is able to reads in bar code and prints out the zip code it represents. Print an error message if the bar code is not correct.

ECRLOT ** CO57 CODE C671RTS2 JOHN DOE 1009 FRANKLIN BLVD SUNNYVALE CO57 CA 95014-5143 Il.lll.llull,lullillnullu

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!