Goal: Print Address with POSTNET bar code. (POSTNET means Postal Numeric Encoding Technique.)
Here is an example of such an address:
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:
Anna Lee,123 Nice Street,Memphis,TN,38141-8346 Stan Smith,456 De La Vina Street,Santa Barbara,CA,93101-3298
Anna Lee 123 Nice Street Memphis TN 38141-8346 |::||:|::|::::||:|::|:::|||::|:::||::|::|:||::::|:|| Stan Smith 456 De La Vina Street Santa Barbara CA 93101-3298 ||:|::::||::::||||::::::||::||:::|:||:|::|::|::|::||
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|---|---|---|---|---|---|---|---|---|
||::: | :::|| | ::|:| | ::||: | :|::| | :|:|: | :||:: | |:::| | |::|: | |:|:: |
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 |.
checksum %= 10Putting this together, you can compute the checksum like this:
checksum = (10 - sumOfDigits % 10) % 10See this article for more details:
public static String getBarCode(String zipcode)
Grading Breakdown: main method: 35%; getBarCode method: 30; User Prompts: 10%; Comments: 10%; Indentation: 10%; Submitted Correctly: 5%