Problem 2.

Create a new java file called Barcode.java that will check to see if a given barcode number is valid. Barcodes have a 12 digit number on them that is used to determine the validity of the code. This is done by summing the odd position digits (1,3,5,7,9 and 11), multiplying this number by 3, then add the sum of all the even position digits(0,2,4,6,8,10 and 12) to this sum. If this sum is divisible by 10, then the barcode is valid. An example using the UPC code 214786948344 is shown below.

1. Sum all of the odd position digits (1,3,5,7,9 and 11).

2 + 4 + 8 + 9 + 8 + 4 = 35

2. Multiply the sum from step 1 by 3.

35 * 3 = 105

3. Sum all of the even position digits (2,4,6,8,10 and 12).

1 + 7 + 6 + 4 + 3 + 4 = 25

4. Add the sums from step 2 and 3 together.

105 + 25 = 130

Because 130 is divisible by 10, the barcode is valid.

For your program, you pass in a 12-digit number (of type long) using the nextLong() method of the Scanner class. Then it should output the remainder of your sum % 10. If the remainder is 0, the barcode is valid. Some sample outputs are shown below.

Input a 12-digit barcode:

214786948344

The barcode is valid if the output is 0.

Output = 0.

Input a 12-digit barcode:

446789001235

The barcode is valid if the output is 0.

Output = 3.

Input a 12-digit barcode:

758392346117

The barcode is valid if the output is 0.

Output = 4.

Thank you very much!!!