Question: C++ on Windows. Objectives: Use functions, loops, and input/output streams The US Postal Services uses bar codes to represent zip codes in order to sort
C++ on Windows.


Objectives: Use functions, loops, and input/output streams The US Postal Services uses bar codes to represent zip codes in order to sort them quickly using machines. The machine will read the bar code and direct the letter to the right location. Write a C++ program that generate bar codes. The program should read the zip codes from an text file and determine the complete bar codes. All the codes along with the zip codes must be stored in another file. The program must ask the user for both the input and output file names. Your program should generate the codes repeatedly from the file until the end of the input file is reached. Your program should output an error message if the zip code read is invalid (for example, non-digit character, fewer or more than 5 digits). See sample output file below. Bar Codes The code is represented by a series of short and long bars. The following table shows the barcodes for each digit. Value Encoding 1 2 ulil 3 4 5 6 7 lul 8 9 0 II. Use ':' and 'l' to represent short and long bars. A check digit is also added at the end of the barcode. The check digit is determined by totaling all the digits of the zip code and adding a digit that makes the sum divisible by 10. For example, if the sum of all the digits is 38 then the check digit is 2, if the sum is 40 the check digit is o, etc. A long bar is added at the beginning and at the end of the barcode (total of 32 bars). The following is an example of the code 45701 (sum = 17, check digit is 3) | :1:1 4 :1:1: ::: ||::::::|| 5 7 0 1 ::11: 3 Check Digit Your program must include at least the following two functions (do not change the names or the prototypes): string getDigitcode (char digit): return a barcode for a single digit int getcheckDigitValue (int sum) : return the check digit You are encouraged to add other functions. Sample Input File (The sample file zips.txt is included with your repository): 45701 456 56-45 564565 12345 The sample file zips.txt is included with your repository. Sample Output File: 45701 456 56-45 564565 12345 1:1::1:1:1:1:::|||::: :::||::||:| Error: zip code must be 5 digits Error: Code is invalid Error: Code is invalid |:::||::1:1::||: :1:::1:1: :1:1:1 Sample user interface: Enter the input file name: zips.txt Enter the output file name: codes.txt The file codes.txt has been created
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
