->Homepage
->Schedule
->Courses
-->CS182
-->Tentative Schedule
-->Objectives
-->Quiz 1
-->Lab 1
-->Lab 2
-->Lab 3
-->Lab 4
-->Lab 5
-->Lab 6
-->Lab 7
-->Project
-->CS183
-->CS285
->Course Policies
->Electronic Submission
->Documentation Standards
->Old Exams
->C++ Examples
->MSVC++ Info
->Software
->Support Forum
->Unix Info
->Nature Photos

[Home]
[Rich][Home][Rich]
[Author]
CS182 -- Lab 4: Bar Codes

Winter 2003-2004

--
Overview

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

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 program that will ask the user to enter a zipcode and will display the corresponding bar code string.
    • Use : for short bars and | for tall bars.
    • If one of the characters entered does not represent a digit, then display the following error string for the digit and the check digit: :::::
    • If more than five digits are entered the program should code the first five digits correctly and then use the above error code for the check digit.
Just for Fun

Write a program that will do the conversion in the opposite direction.

Lab report (due 11:00pm, the day prior to week 5 lab)

Here is a template file to use as a starting point for this report.

The lab report does not need to be self-contained. Your report should include:

  • Discussion (sample program output, problems you encountered (and how they were overcome), etc.)
  • An activity log indicating how much time you spent on each phase of the assignment. You should use the format found in the template XML file and report the time in the following categories:
    • Design
    • Coding
    • Debug (before you think it's working)
    • Test (after you think it's working)
    • Writing Report
    • Other
  • Conclusions (what you learned, suggestions of how the assignment could be improved, things you would have done differently, etc.)
  • Documented source code for your program.

As with any report you submit, correct spelling and grammar are required. In addition, your report should be submitted electronically following the Electronic submission guidelines. (You may wish to consult the XML help video and/or sample report before submitting your report.) 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, clarity of code and documentation, as well as whether your program produces the correct results. If you have any questions, consult your instructor.

Acknowledgment

This laboratory assignment was developed by Dr. Chris Taylor, and is based on an exercise from Computing Concepts with C++ Essentials, 2nd ed. by Cay Horstmann.

Last Updated: Thursday, 01-Jan-2015 13:33:42 CST