Verify the check digit in a barcode. Some of the most common barcode standards have check digits which are fairly easy to calculate.

UPC (12 digits) are among the most common barcode standards you will find. The check digit is calculated like this:

•the right-most digit is the check digit which we want to verify

•if you have a 12-digit barcode, add a zero to the beginning - e.g. 008811908027 becomes 0008811908027

•considering the left-most digit to be in position 0 and ignoring the check digit, sum the digits in odd-numbered positions (0 + 8 + 1 + 9 + 8 + 2 = 28) and multiply the result by 3 (84)

•sum the digits in even-numbered positions (0 + 0 + 8 + 1 + 0 + 0 = 9)

•add those two results together (93) then calculate that total modulo 10 (93 % 10 = 3)

•if the answer is 0 then that is the check digit, otherwise subtract the result from 10 to give the check digit (7)

Sample Data:
UPC Code of 829160697413 should evaluate to 3.
UPC Code of 9780972705530 should evaluate to 0.

Do your own work.

Public void tester(string x){

System.out.println(" Do your own java lab, Solomon");

}

To verify the check digit in a barcode, you can follow these steps:

1. Take the UPC barcode, if it has 12 digits, add a zero to the beginning. For example, "008811908027" becomes "0008811908027".

2. Consider the leftmost digit to be in position 0 and ignore the check digit. Sum the digits located in the odd-numbered positions. In our example, the odd-numbered positions are 0, 2, 4, 6, 8, and 10. Add these digits: 0 + 8 + 1 + 9 + 8 + 2 = 28.

3. Multiply the sum of the odd-numbered digits by 3. In our example, 28 * 3 = 84.

4. Sum the digits located in the even-numbered positions. In our example, the even-numbered positions are 1, 3, 5, 7, and 9. Add these digits: 0 + 0 + 8 + 1 + 0 = 9.

5. Add the results from steps 3 and 4 together. In our example, 84 + 9 = 93.

6. Calculate the total from step 5 modulo 10. In our example, 93 % 10 = 3.

7. If the result from step 6 is 0, then the check digit is also 0. Otherwise, subtract the result from 10 to get the check digit. In our example, 10 - 3 = 7.

So, the check digit for the UPC code "829160697413" evaluates to 3.

For the UPC code "9780972705530", the check digit should evaluate to 0. You can follow the same steps above, and in this case, the result from step 6 is 0. Therefore, the check digit is 0.