CS150 -- Lab 5: Postal Bar Codes



->Courses
->CS150
-->Homework
-->Lab 1
-->Lab 2
-->Lab 3
-->Lab 4
->Lab 5
-->Lab 6
-->Lab 7
->Electronic Submission
->Old Exams
->C++ Examples
->MSVC Info
->Software
->Tentative Schedule
->Course Policies

[Courses]
[Rich][Home][Rich]
[Author]

Fall Quarter 2000

Overview

In this lab, you will write a program to produce postal bar codes.

Acknowledgement

This laboratory assignment is based on an exercise from Computing Concepts with C++ Essentials, 2nd ed. by Cay Horstmann.

Procedure

Postal bar codes are used by the United States Postal Service to automate mail sorting. The bar codes are more easily scanned by a computer that the numbers we like to use. A bar code consists of a sequence of tall and short bars. There is a tall bar at the beginning and end of the bar code. Each digit is represented by 5 bars and an additional 5 bars are used to check the validity of the bar code. A total of 32 bars are used to represent a five digit zipcode. For example, the bar code for 53222 is:

|:|:|:::||:::|:|::|:|::|:|:||::|
where | represents a tall bar and : represents a short bar.

Each digit in the code is converted as follows:

1 -- :::||
2 -- ::|:|
3 -- ::||:
4 -- :|::|
5 -- :|:|:
6 -- :||::
7 -- |:::|
8 -- |::|:
9 -- |:|::
0 -- ||:::

To find the value of the check digit, you need to add all of the digits together and choose the check digit to make the sum a multiple of 10. (In the above example I chose the check digit to be 6 because 5+3+2+2+2+6=20.)

  • Write a function when that passed a one character string, will return the corresponding five character bar code string.
    • Use : for short bars and | for tall bars.
    • If the one character string passed in does not represent a digit, then return the following error string: :::::
  • Write a program that asks the user for a zipcode and prints the bar code. Your program should call the function described above.
  • After each zipcode to bar code translation, your program should ask the user whether or not he/she wishes to enter another zipcode.

Lab Report (due beginning of week 8 lab)

This lab report need not be self-contained. At a minimum, your report should include:

  • A brief discussion of what you learned and what problems you encountered.
  • Sample output from your program for the following zipcodes: 49706, 57606 and 53202.
  • Documented source code (you may wish to include this at the end of your report)
  • Any suggestions on how the lab could be improved.

Your report should be typed, and as with any report you submit, correct spelling and grammar are required. Be sure to keep copies of all your files, in case something gets lost. It may be wise to keep a diskette backup as well.

Your grade will depend on quality of design and clarity of the code and documentation, as well as whether your program produces the correct results. If you have any questions, consult the instructor.

Office: CC-27C, Phone: 277-7339
Last Updated: July 30, 2000
© 2000 Dr. Christopher C. Taylor