Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is the StdDraw.java library to copy/paste: https://pastebin.com/pd8pja0f Overview: Postal barcode (Exercise 2.1.36). The initial barcode used by the U.S Postal System to route mail

image text in transcribed

image text in transcribed

Here is the StdDraw.java library to copy/paste:

https://pastebin.com/pd8pja0f

Overview: Postal barcode (Exercise 2.1.36). The initial barcode used by the U.S Postal System to route mail is defined as follows: Each decimal digit in the ZIP code is encoded using a sequence of three half-height and two full-height bars. The barcode starts and ends with a full-height bar (the guard rail) and includes a checksum digit (after the five-digit ZIP code or the nine-digit ZIP +4 code), computed by summing up the original digits modulo 10 Implement the following functions . Draw a half-height or full-heigh bar on StdDraw. Given a digit, return the binary code of that digit as a String * Compute the checksum digi . Given a String of 1's and 0's, draw the corresponding barcode in which 1's are full- height bars and 0's are half-height bars. The barcode should be centered in the StdDraw canvas Implement a test client that reads in a five or nine digit ZIP code as the command line argument and draws the corresponding postal barcode Details: . Name the program PP2.java. . Use the following table to map a digit to barcodes digit bar code binary code 0 11000 00011 00101 00110 01001 01010 01100 10001 10010 10100 9 The binary code use 1 for full-height and 0 for half-height bars of the barcode The width of a bar should be T of the height of the full-height bar . The space between bars should be the same as the width of a bar Current postal bar code uses four different size bars and encodes additional tracking information . Use an appropriate height to make it easy to see the barcode when displayed (if printed we would want 24 bars per inch) . The checksum digit is the value when added to the sum of the original digits, causes the sum modulo 10 to be zero. Example: digits 0 8 5 4 0 would sum to 17. The checksum would be 3 as (17+3) modulo 10 is zero. Note that this differs from the textbook example of 7 Validate the command line parameters. If invalid values are given then print out a warning message Your program should display your name and lab CRN at the top of the StdDraw canvas showing the barcode. StdDraw provides a set of functions for writing text to the display . The original Zip code and the calculated checksum digit should be displayed at the bottom of the StdDraw canvas the barcode should be centered in the middle of the StdDraw canvas Overview: Postal barcode (Exercise 2.1.36). The initial barcode used by the U.S Postal System to route mail is defined as follows: Each decimal digit in the ZIP code is encoded using a sequence of three half-height and two full-height bars. The barcode starts and ends with a full-height bar (the guard rail) and includes a checksum digit (after the five-digit ZIP code or the nine-digit ZIP +4 code), computed by summing up the original digits modulo 10 Implement the following functions . Draw a half-height or full-heigh bar on StdDraw. Given a digit, return the binary code of that digit as a String * Compute the checksum digi . Given a String of 1's and 0's, draw the corresponding barcode in which 1's are full- height bars and 0's are half-height bars. The barcode should be centered in the StdDraw canvas Implement a test client that reads in a five or nine digit ZIP code as the command line argument and draws the corresponding postal barcode Details: . Name the program PP2.java. . Use the following table to map a digit to barcodes digit bar code binary code 0 11000 00011 00101 00110 01001 01010 01100 10001 10010 10100 9 The binary code use 1 for full-height and 0 for half-height bars of the barcode The width of a bar should be T of the height of the full-height bar . The space between bars should be the same as the width of a bar Current postal bar code uses four different size bars and encodes additional tracking information . Use an appropriate height to make it easy to see the barcode when displayed (if printed we would want 24 bars per inch) . The checksum digit is the value when added to the sum of the original digits, causes the sum modulo 10 to be zero. Example: digits 0 8 5 4 0 would sum to 17. The checksum would be 3 as (17+3) modulo 10 is zero. Note that this differs from the textbook example of 7 Validate the command line parameters. If invalid values are given then print out a warning message Your program should display your name and lab CRN at the top of the StdDraw canvas showing the barcode. StdDraw provides a set of functions for writing text to the display . The original Zip code and the calculated checksum digit should be displayed at the bottom of the StdDraw canvas the barcode should be centered in the middle of the StdDraw canvas

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

24. In Prob. 23, find x.

Answered: 1 week ago