subject

A barcode scanner for Universal Product Codes (UPCs) verifies the 12-digit code scanned by comparing

the code’s last digit (called a check digit ) to its own

computation of the check digit from the first 11 digits as follows:
I. [step 1]Calculate the sum of the digits in the
odd-numbered positions (the first, third, ...,
eleventh digits) and multiply this sum by 3.

II. [step 2]Calculate the sum of the digits in the
even-numbered positions (the second, fourth, ...,
tenth digits) and add this to the previous
result(result of step1).

III. [step 3]If the last digit of the result from step
2 is 0, then 0 is the check digit. Otherwise,
subtract the last digit from 10 to calculate the
check digit.

IV. [step 4]If the check digit matches the final
digit of the 12-digit UPC, the UPC is assumed
correct.

1. Write main function that prompts the user to
enter the 12 digits of a barcode. The program
should store the digits in an integer array.

2. Write a “check” function to calculate the check
digit, and compare it to the final barcode digit.
If the digits match, output the barcode with the
message “validated.” If not, output the barcode
with the message “error in barcode.” Also, output
with labels the results from steps 1 and 2 of the
check-digit calculations. Note that the “first”
digit of the barcode will be stored in element 0
of the array. (clue: “check” function takes two
argument and it doesnt return any value)

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 00:00
Suppose you have 9 coins and one of them is heavier than others. other 8 coins weight equally. you are also given a balance. develop and algorithm to determine the heavy coin using only two measurements with the of the balance. clearly write your algorithm in the form of a pseudocode using the similar notation that we have used in the class to represent sorting algorithms
Answers: 1
question
Computers and Technology, 23.06.2019 07:00
Why were most movies from the late 1890s until the early 1930s only filmed in black and white? there were only a few people who could afford the technology to produce color motion pictures back then. audiences did not want color motion pictures until later. the film used to make color motion pictures often overheated, which was a safety hazard, so it was generally not allowed. color films had to be hand-colored, frame by frame.
Answers: 3
question
Computers and Technology, 23.06.2019 14:30
Which of the following would not be considered a pc? a. mainframe b. desktop c. tablet pc d. laptop
Answers: 2
question
Computers and Technology, 23.06.2019 19:00
Acompany is hiring professionals for web designing. the firm is small with few resources. they want employees who possess problem-solving skills and can independently carry out responsibilities. which kind of employee should they select?
Answers: 2
You know the right answer?
A barcode scanner for Universal Product Codes (UPCs) verifies the 12-digit code scanned by compari...
Questions
question
Mathematics, 29.10.2020 23:10
question
Mathematics, 29.10.2020 23:10
question
Mathematics, 29.10.2020 23:10
question
Chemistry, 29.10.2020 23:10
question
Mathematics, 29.10.2020 23:10
question
History, 29.10.2020 23:10
Questions on the website: 13722367