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.

2 answers

Do your own work.
Public void tester(string x){
System.out.println(" Do your own java lab, Solomon");

}