To Documents

IT 313 -- Project 4

POSTNET Bar Codes

Goal: Print Address with POSTNET bar code. (POSTNET means Postal Numeric Encoding Technique.)
Here is an example of such an address:
 
POSTNET Codes
 
We use the vertical line ( | ) to represent the long vertical bar and semicolon ( : ) to represent the short vertical bar

Input File:   addresses.txt (Naming this input file with a .csv extension is also okay, but then it opens up in Excel if you double click on its name in the Windows Explorer.)

Relevant Examples: JFileChooser class in InputOutput; Morse code files.

Details:

  1. For this project, place your class file or files in a package named it313.dixonc, where you replace dixon with your last name and c with the first initial of your first name.
  2. Read an input CSV file containing addresses using a Scanner object. Don't redirect from stdin, read directly from the file. Here are two sample lines from a mailing list:
    Anna Lee,123 Nice Street,Memphis,TN,38141-8346
    Stan Smith,456 De La Vina Street,Santa Barbara,CA,93101-3298 
    
  3. Obtain the input file using a JFileChooser dialog. Before the file chooser is displayed, print a message explaining what to enter in the file chooser. See the UseFileChooser class in the InputOutput Example.
  4. For each line write out an address like this to the output file output-labels.txt:
    Anna Lee
    123 Nice Street
    Memphis TN 38141-8346
    |::||:|::|::::||:|::|:::|||::|:::||::|::|:||::::|:||
    
    Stan Smith
    456 De La Vina Street
    Santa Barbara CA 93101-3298
    ||:|::::||::::||||::::::||::||:::|:||:|::|::|::|::||
    
  5. The bar code is encoded using this table:
    0 1 2 3 4 5 6 7 8 9
    ||::: :::|| ::|:| ::||: :|::| :|:|: :||:: |:::| |::|: |:|::

    In addition to encoding the 9 digits of the zip code, the bar code includes initial (i) and terminal (t) frame bars and a check sum (cs), which is 10 - the sum of the zip code digits mod 10. Thus the zip code 38141-8346 is encoded like this:
    i   3     8     1     4     1     8     3     4     6     cs  t
    | ::||: |::|: :::|| :|::| :::|| |::|: ::||: :|::| :||:: ::|:| | 
    
    The sum of the digits is 38 and 38 % 10 is 8, so the check sum is 10 - 8 = 2. The initial and terminal frame bars are always |.
    Note: If the sum of the digit % 10 is 0, the check sum is 10 - 0 = 10, which should be replaced by 0. This can be done with an if statement, or with
    checksum %= 10
    
    Putting this together, you can compute the checksum like this:
    checksum = (10 - sumOfDigits % 10) % 10
    
    See this article for more details:
      http://en.wikipedia.org/wiki/POSTNET
  6. Write and use this method (or have IntelliJ extract it via refactoring):
    public static String getBarCode(String zipcode)
    

Grading Breakdown:   main method: 35%; getBarCode method: 30; User Prompts: 10%; Comments: 10%; Indentation: 10%; Submitted Correctly: 5%