Question: kindly give in copy paste format A barcode scanner for Universal Product Codes (UPCs) verifies the 12-digit code scanned by comparing the code's last digit

 kindly give in copy paste format A barcode scanner for Universal

kindly give in copy paste format

A barcode scanner for Universal Product Codes (UPCs) verifies the 12-digit code scanned by comparing the code's last digit (called as check digit) to its own computation of the check digit from the first 11 digits as follows: 1. Calculate the sum of the digits in the odd numbered positions (the first, third, .*. eleventh digits) and multiply this sum by 3. 2. Calculate the sum of the digits in the even-numbered positions (the second, fourth, ..., tenth digits) and add this to the previous result, to get dig_Sum. 3. If the last digit of the result from step 2 is o, then the check digit is 0. Otherwise, check digit is obtained by subtracting the last digit of dig_Sum from 10 (10 - last digit of dig_Sum). write a python program to read the barcode, if the number of digits is not 12 then print "Cannot be processed" and terminate program. Otherwise calculate the check digit, and compare it to the last barcode digit. If the digits match, output the barcode with the message "Validated". If not, output the barcode with the message "Error in barcode." For example the barcode code 079400804501, the result from step 2 is 79 0 + 9+ 0 + 8 + 4 + 0) * 3 + (7 + 4+ 0 + 0 + 5). Since the last digit is 9, the check digit is 10 - 9 = 1 and this matches the last digit of USD therefore print Validated'. Input format Barcode Output If the number of digits is not 12, then print "Cannot be processed

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!