barcode scanner for Universal Product Codes(UPCs) verifies the 12-digit code scanned by comparing thecode’s last digit (called a check digit ) to its owncomputation of the check digit from the first 11 digits asfollows:I. [step 1]Calculate the sum of the digits in theodd-numbered positions (the first, third, …,eleventh digits) and multiply this sum by 3.II. [step 2]Calculate the sum of the digits in theeven-numbered positions (the second, fourth, …,tenth digits) and add this to the previousresult(result of step1).III. [step 3]If the last digit of the result from step2 is 0, then 0 is the check digit. Otherwise,subtract the last digit from 10 to calculate thecheck digit.IV. [step 4]If the check digit matches the final digitof the 12-digit UPC, the UPC is assumed correct.1. Write main function that prompts the user to enterthe 12 digits of a barcode. The program shouldstore the digits in an integer array.2. Write a “check” function to calculate the checkdigit, and compare it to the final barcode digit.If the digits match, output the barcode with themessage “validated.” If not, output the barcodewith the message “error in barcode.” Also, outputwith labels the results from steps 1 and 2 of thecheck-digit calculations. Note that the “first”digit of the barcode will be stored in element 0of the array. (clue: “check” function takes twoargument and it doesnt return any value)
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here