CMPU 125 Assignment 3: Checksum Validation

Due on Friday, September 26th, by 5pm.

Problem Specification:

A common requirement for software applications supporting inventory management is to validate the items in stock. For example, suppose a store manager wants to add a new item to the store's inventory database. To do so, the manager would need to insert a new entry into the database that gives the name and price of the item along with its code number. Correctly entering all three pieces of data is important, since an improperly entered code would make it impossible for price scanners to recognize the item.

One way to increase the likelihood of correct data entry is to use checksum software to test whether the digits of a potential code number have some particular property.

For example, there is a verification scheme for the Universal Product Code (UPC) numbers. The familiar UPC in bar code form is shown below.

Fig. 1: UPC bar code 128016691675.

A valid UPC number is a 12-digit value that meets the following criteria:
 

A UML (Unified Modeling Language) diagram for this assignment is shown below. Try to make your classes follow the guidelines shown.



The method evenValues in the UniversalProductCode class returns the sum of the digits in even positions of the upcCode and the oddValues method returns the sum of the digits in odd positions.  The checkValidity method takes the resulting sums and an array of digits and returns true if the upcCode String is valid and false otherwise. There is a getter method for the private boolean variable called valid.
 
Make your program modular. Your solution does not have to match the UML diagram shown exactly, but it should include at least 2 classes. You can add more methods than the ones shown in the diagram above. Remember, no method should be longer than a page and every method should have one well-defined task. Put some time in thinking about how your program will be designed before starting to code.

What you should hand in:

If you have questions, please send e-mail to either soroberts@vassar.edu or walter@cs.vassar.edu. Also, note the coaching hours that are posted on the course web page.