Project 06 Description The Universal Product Code (UPC) is a widely-used standard for barcodes. The standard for one type of UPC (known as UPC-A) says that a valid UPC must be encoded as a 12 digit string where the first 11 digits form the unique code and the final digit is used as a \"check digit\" to ensure that the UPC has been correctly read by the scanner. If the UPC has been correctly read, then the application of a specific algorithm to the first 11 digits of the UPC should give a result equal to the check digit. For this lab you will write a Java program that checks UPC strings to see if they are valid. Your program should first prompt the user to enter a string of numbers as a UPC code, or enter a blank line to quit the program. If the user doesn\'t quit, your program should ensure that this string is exactly 12 characters in length. If the user enters a string that is not 12 characters in length, your program should print an error message and ask again for a valid string. Your program should use the algorithm below to compute what the check digit should be and then compare it to the actual value in the provided string and report whether the UPC is valid or wrong. If it is wrong, your program should report what the correct check digit should be for the input UPC. Your program should keep asking for new UPC until the user enters a blank line to quit the program. The algorithm for checking for a valid UPC is: 1. From left to right, add the digits in the odd-numbered positions (starting the count from 1) and multiply the result by 3 2. From left to right, add the digits in the even-numbered positions to the total computed in step 1 3. Take the result from step 2 and compute the remainder when divided by 10 (result modulo 10). If the remainder is not zero, subtract this remainder from 10 to get the check digit. If the remainder is zero, then the check digit should be o
import java.util.Scanner;
public class ValidationUPC {
final long L = 999999999999L;
Scanner inputUPC = new Scanner(System.in);
System.out.print(\"Enter a 12-digit UPC : \");
long inputUPCC = inputUPC.nextLong();
long CV = inputUPCC;
if ((CV>= 0) && (CV < L)) {
int n12 = (int) (CV % 10);
CV /= 10;
int n11 = (int) (CV % 10);
CV /= 10;
int n10 = (int) (CV % 10);
CV /= 10;
int n9 = (int) (CV % 10);
CV /= 10;
int n8 = (int) (CV % 10);
CV /= 10;
int n7 = (int) (CV % 10);
CV /= 10;
int n6 = (int) (CV % 10);
CV /= 10;
int n5 = (int) (CV % 10);
CV /= 10;
int n4 = (int) (CV % 10);
CV /= 10;
int n3 = (int) (CV % 10);
CV /= 10;
int n2 = (int) (CV % 10);
CV /= 10;
int n1 = (int) (CV % 10);
CV /= 10;
int oddSum = n1 + n3 + n5 + n7 + n9 + n11;
int evenSum = n2 + n4 + n6 + n8 + n10;
int ccheck = 10 - ((evenSum + 3 * oddSum) % 10);
if (ccheck == n12) {
System.out.println(inputUPCC + \" is a valid UPC code\");
}
else {
System.out.println(inputUPCC + \" is not a valid UPC code\");
}
}
public static void main(Strings args[])
{
class ValidationUPC=new ValidationUPC();
}