@@ -0,0 +1,2123 @@
+package year2012;%0A%0Aimport java.util.Scanner;%0A%0A/**%0A * %3Ch3%3EUPC Check Digit%3C/h3%3E%0A * %3Cp%3EThe most common form of Universal Product Code (UPC) is UPC-A%0A * which has 12 digits arranged to make a unique number.%0A * The twelfth digit is a check digit calculated%0A * based on the values in digits one through eleven.%0A * Calculate a UPC-A check digit given the eleven digits.%3C/p%3E%0A *%0A * @author John Cameron%0A * @see %3Ca href=%22https://www.seminolestate.edu/computers/competition/samples/2012%22%3EProblem Descrption and Requirements%3C/a%3E%0A */%0Apublic class UPCCheckDigit %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A        Scanner scanner = new Scanner(System.in);%0A%0A        String input = scanner.nextLine();%0A        char%5B%5D inputChars = input.toCharArray();%0A%0A        scanner.close();%0A%0A        if (input.length() != 11)%0A            throw new IllegalArgumentException(%22Input must be 11 digits only%22);%0A%0A        int checkNumber = 0;%0A%0A        //Add the digits in the odd numbered positions (first, third, fifth, ...)%0A%0A        int sumOddDigits = 0;%0A%0A        for (int i = 0; i %3C 11; i += 2) %7B%0A%0A            int digit = Character.getNumericValue(inputChars%5Bi%5D);%0A%0A            sumOddDigits += digit;%0A%0A        %7D%0A%0A        checkNumber += sumOddDigits;%0A%0A        //Multiply the above sum by three.%0A%0A        checkNumber *= 3;%0A%0A        //Add the digits in the even numbered positions (second, fourth, sixth, %E2%80%A6) to the total from above%0A%0A        int sumEvenDigits = 0;%0A%0A        for (int i = 0; i %3C 11; i++) %7B%0A%0A            if (i %25 2 == 0)%0A                continue;%0A%0A            int digit = Character.getNumericValue(inputChars%5Bi%5D);%0A%0A            sumEvenDigits += digit;%0A%0A        %7D%0A%0A        checkNumber += sumEvenDigits;%0A%0A        //Find the remainder when you divide the result by ten%0A%0A        int remainder = (checkNumber %25 10);%0A%0A        //The check digit is zero if the remainder is zero%0A%0A        if (remainder == 0)%0A            checkNumber = 0;%0A        else ////Otherwise subtract the remainder from ten to get the check digit.%0A            checkNumber = 10 - remainder;%0A%0A        System.out.println(%22Check digit for %22 + input + %22 is %22 + checkNumber);%0A%0A%0A    %7D%0A%0A%7D%0A

Add UPC Check Digit (2012) solution