UPC+checker

= UPC Checker = To begin, you will bring a UPC code and show me it is valid by using math. For those of you that don’t know, there is a neat mathematical formula that is involved in validating UPC codes.

This UPC code above has actually 11 digits. The 3 on the left is the 1st digit while the 11th digit is a 1. The 7 on the far right is called the //check digit//.

The formula is as follows:

3 x (Sum of Odd Positions (i.e. 1st, 3rd, 5th,…digit)) + (Sum of Even Positions) = Z

You then take the number Z and subtract it from the next multiple of 10.

= =

Example for UPC seen above
3x(3 + 0 + 4 + 6 + 6 + 1) + (0 + 7 + 6 + 0 + 0) = 73

Next multiple of 10 is 80. So 80 – 73 = 7. The check digit shows this UPC code is VALID.

Your Assignment
Create a website that takes in a 12 digit value, then tells you whether the input is a valid UPC code or not. Fancy up your website using CSS.

Here's a [|copy of the Python version] we created together in class. It's ugly, but functional.