Question: Please write in C++ 3. [30 pts) POSTNET Barcode The USPS used a code named POSTNET to direct mail based on ZIP code until 2009.

Please write in C++

Please write in C++ 3. [30 pts) POSTNET Barcode The USPS useda code named POSTNET to direct mail based on ZIP code until

3. [30 pts) POSTNET Barcode The USPS used a code named POSTNET to direct mail based on ZIP code until 2009. The bar code consists of full- or half-bars as shown in Figure 2. Figure 2: Example Postnet Barcode IIIIIIIIIIIII The codes are encoded as 1 for a full bar and 0 for half bar. The bar code above would then be encoded as: 110100101000101011000010011. The first and last digits of the bar code are always 1. Removing these leaves 25 digits or a 5-digit ZIP code. For the code above the digits are encoded as follows: 1010010100010101100001001. Each decimal digit is encoded as 5 bars (2 full, 3 half) such that each digit corresponds to a given weight as follows (left to right) 7, 4, 2, 1, 0. Multiply the corresponding value with the digit and compute the sum to get the final encoded digit for the zip code. The digit '0' is special, encoded as 11000 or a decimal 11, as there have to be two full bars per digit. The entire encoding is given in the Figure 3. Figure 3: Postnet Barcode Encoding Numeric Binary codo Barcode Value Value 00011 Value 00101 uu ul. 00110 01001 01010 01100 L.L. II.. 10001 10010 ul 10100 11000 TL Write a Zipcode class that encodes and decodes five-digit bar codes used in POST NET. The class should have two constructors. First constructor should input the zip- code as an integer and the second constructor should input the zip code as a bar code string consisting of Os and is as described above. Although you have two ways to in put the zip code, internally the class should only store the zip code using the integer format. The class should have at least two public member functions: one to return zip code as an integer and the other to return it as a string. Any other helper fune- tions should be declared as private. Show the output of your code for the following two cases: 23156 and "110100110000010100011110001". 3. [30 pts) POSTNET Barcode The USPS used a code named POSTNET to direct mail based on ZIP code until 2009. The bar code consists of full- or half-bars as shown in Figure 2. Figure 2: Example Postnet Barcode IIIIIIIIIIIII The codes are encoded as 1 for a full bar and 0 for half bar. The bar code above would then be encoded as: 110100101000101011000010011. The first and last digits of the bar code are always 1. Removing these leaves 25 digits or a 5-digit ZIP code. For the code above the digits are encoded as follows: 1010010100010101100001001. Each decimal digit is encoded as 5 bars (2 full, 3 half) such that each digit corresponds to a given weight as follows (left to right) 7, 4, 2, 1, 0. Multiply the corresponding value with the digit and compute the sum to get the final encoded digit for the zip code. The digit '0' is special, encoded as 11000 or a decimal 11, as there have to be two full bars per digit. The entire encoding is given in the Figure 3. Figure 3: Postnet Barcode Encoding Numeric Binary codo Barcode Value Value 00011 Value 00101 uu ul. 00110 01001 01010 01100 L.L. II.. 10001 10010 ul 10100 11000 TL Write a Zipcode class that encodes and decodes five-digit bar codes used in POST NET. The class should have two constructors. First constructor should input the zip- code as an integer and the second constructor should input the zip code as a bar code string consisting of Os and is as described above. Although you have two ways to in put the zip code, internally the class should only store the zip code using the integer format. The class should have at least two public member functions: one to return zip code as an integer and the other to return it as a string. Any other helper fune- tions should be declared as private. Show the output of your code for the following two cases: 23156 and "110100110000010100011110001

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!