Question: Postal bar codes. For faster sorting of letters, the United States Postal Service encourages companies that send large volumes of mail to use a bar
Postal bar codes. 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 7). The encoding scheme for a five-digit zip code is shown in Figure 8. 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 sum 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.

The digit can be easily computed 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
![]()
Provide these methods:
public static void printDigit(int d)
public static void printBarCode(int zipCode)
***** ECRLOT ** CO57 CODE O671RTS2 JOHN DOE 1009 FRANKLIN BLVD Frame bars CO57 SUNNYVALE CA 95014 - 5143 Digit 1 Digit 2 Digit 3 Digit 4 Digit 5 Check Digit Figure 7 A Postal Bar Code Figure 8 Encoding for Flve-Digit Bar Codes Each digit of the zip code, and the check digit, is encoded according to the table below, where 1 denotes a full bar and O a half bar: Bar 1 Bar 2 Bar 3 Bar 4 Bar 5 Digit (welght 7) (welght 4) (welght 2) (welght 1) (welght 0) 1 1 1 1 3. 1 1 4 1 1 1 6. 1 1 7. 1 8. 1 1 1 1
Step by Step Solution
3.45 Rating (164 Votes )
There are 3 Steps involved in it
CODE Main Function include include using namespace std string GetBarcodelong int main long postal cout Enter a Zip code number cin postal cout The bar... View full answer
Get step-by-step solutions from verified subject matter experts
