Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The US Postal Services uses bar codes to represent zip codes in order to sort them quickly using machines. The machine will read the

  

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 code and determines the complete bar code. 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 3 4 5 lal G illu 7 8. Inh 9 Th 0 Use and 'I' 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 0, 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) 4 5 7 0 1 3 Check Digit Your program should generate the codes repeatedly until the user decided to quit. Your program should print an error message if the zip code entered is invalid (for example, non-digit character, fewer or more than 5 digits). 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 Run: Enter a zip code: 45701 Code: 1:1:1:1:1: More codes (y/n)? y Enter a zip code: 456 Error: zip code must be 5 digits More codes (y/n)? y Enter a zip code: 56-45 Error: Code is invalid More codes (y/n)? y Enter a zip code: 564565 Error: Code is invalid More codes (y/n)? y Enter a zip code: 12345 Code: :::||::|:|::|::|::|::|:1:1 More codes (y/n)? n Grading: Programs that contain syntax errors will earn zero points. Programs that do not include functions other than main, will also earn zero points. Programs that use global variables other than constants, will earn zero points. Programs that use libraries NOT discussed in class will earn zero points. Your grade will be determine using the following criteria: . Correctness: the program works as requested above (35 points). (5 points) The code is printed correctly (32 bars) o (20 Points) The required functions are implemented o (10 points) Error checking

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Based on the instructions provided in the images youve shared we need to create a C program that converts a given zip code into a barcode pattern usin... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Discovering Advanced Algebra An Investigative Approach

Authors: Jerald Murdock, Ellen Kamischke, Eric Kamischke

1st edition

1559539844, 978-1604400069, 1604400064, 978-1559539845

More Books

Students also viewed these Programming questions

Question

Prove the combinatorial identity?

Answered: 1 week ago

Question

What does stickiest refer to in regard to social media

Answered: 1 week ago

Question

What is an externality?

Answered: 1 week ago