Posted by JAZZY on Wednesday, November 24, 2010 at 3:59pm.
For faster sorting of letters, the postal service encourages companies that send large volumes of mail to use bar code denoting the ZIP code (see figure below).
PO Box 34689 Jeddah
There are full height frame bars on each side. The five encoded digits are followed by a check digit, which is computed as follows. Add up all digits, and choose the check digit to make the sum a multiple of 10. For example, the sum of the digits in the ZIP code 21478 is 22, so the check digit is 8 to make the sum equal to 30.
Each digit of the ZIP code, and the check digit, is encoded according to the following table, where 0 denotes a half bar and 1 a full bar.
Note that they represent all combinations of two full and three half bars. The digit can be computed easily from the bar code using the column weights 7, 4, 2, 1, 0. For example, 01100 is
0.7+1.4+1.2+0.1+0.0 = 6
The only exception is 0, which will yield 11 according to the weight formula.
Write a program that asks the user for a ZIP code and prints the bar code. Use ‘:’ for half bars, | for full bars. For example, 21478 becomes
| | : : | : : : : | | : | : : | | : : : | : : | : | : : | : |
You are requested to design the appropriate classes and supply the appropriate methods. Your solution must be Object Oriented (OO).
- programming java - MathMate, Thursday, November 25, 2010 at 12:41am
You will certainly need a class and associated methods for decoding and printing the bar-codes.
Whether you would make a class to encapsulate the input and output is up to you, or your instructor.
The instructions for printing the bar-code looks complex, but it is the easy part, and fun to do.
Do some high-level planning (classes, methods, state variables, etc.) before plunging into the pseudocode, or actual coding.
Post if you have progress or problems.
Answer this Question
Computer programming - Sorting is a common operation used in programming. ...
java programming - write a java program using arrays function for hotel bill ...
programming.Java language - Write a program to plot a face. Provide a class ...
Computer Programming - How do I understand how Java programming works?
JAVA PROGRAMMING - "POWERS" Compute the power of a number given the base and ...
Computer Language Java - What is the concept of multi-threading in java and how ...
Computer Information - A __________ provides the tools that a programmer uses to...
Java Programming - I'm new to Java and I'm not sure how to write the source code...
sorting - sorting the same set in different ways
Computer science (Java programming) - Why are the use of GUIs and graphics ...