recitation0 - 15-100 RECITATION 0 - FALL 2007 The U.S. Post...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 15-100 RECITATION 0 - FALL 2007 The U.S. Post Office speeds its delivery of mail by the use of a postal bar code. Each digit of the 5-digit zip code is encoded using one of the 10 patterns shown below: Number Bar code ----------------0 ||... 1 ...|| 2 ..|.| 3 ..||. 4 .|..| | represents a tall bar . represents a short bar For example, if your zip code is 15213, then the barcode that should be generated is: ...||.|.|...|.|...||..||. Number Bar code -----------------5 .|.|. 6 .||.. 7 |...| 8 |..|. 9 |.|.. Exercise Using Eclipse, write a simple Java program in a project named Recitation0 that contains a class named BarCodeGenerator with a main method that prints out the barcode of the zipcode of your current home address (if you live on campus, your zipcode is 15213). 1. You should write simple static methods to print out the barcode pattern for each digit that you need (one pattern per method). For example, for the zipcode 15213, you would need four static methods, since there are four unique digits. One of the static methods might be named printOne and it would print out ...|| on the screen. 2. Then use your main method to call these methods in the correct order to print out the desired bar codes. 3. Include a comment at the top of your program that tells us what your home zip code is so we can check your answer. Advanced Exercise (if you have time) Once you get the program above to work correctly, modify your program so that it contains 10 static methods (besides main) to print out each barcode pattern, one method for each number. Then find out how real US postal barcodes are encoded by visiting Modify your program so that the main method calls the other static methods in the correct order to print out the correct postal bar code for the following address*: Homer J. Simpson 742 Evergreen Terrace Springfield, OR 97477-1357 *DISCLAIMER: There is no evidence from The Simpsons that suggests that Homer Simpson really lives in Oregon. When You're Done... 1. Create a zip file of the project folder for this recitation. (On the Mac, you do this by navigating to your workspace. Hold the control key down and click on the recitation project folder and choose "Create archive of..." to create a zip file for submission.) 2. Go to Blackboard and log in. 3. Navigate to the 15-100 course area. 4. Click on Recitations in the left column. 5. You will see an entry for Recitation with a link "View/Complete Assignment: Recitation". Click this link and follow the instructions shown to SUBMIT your zip file for review. DO NOT ERASE YOUR RECITATION PROJECT FOLDER IN CASE WE NEED TO SEE IT LATER (IF THE SUBMISSION IS DONE INCORRECTLY). ...
View Full Document

This note was uploaded on 01/25/2010 for the course CS 15100 taught by Professor Tom during the Fall '07 term at Carnegie Mellon.

Ask a homework question - tutors are online