A barcode scanner for Universal Product Codes (UPCS) verifies the 12-digit code scanned by comparing the code's largest digit (called a 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 position (the second, fourth..tenth digits) and add this to the previous result. 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. 4. If the check digit matches the final digit of the 12-digit UPC, the UPC is assumed correct By using C++ write a program that prompts the user to enter the 12 digits of a barcode separated b space. The program should store the digits in an integer array, 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 step 1 and 2 of the check-digit calculations. Note that the "first" digit of the barcode will be store in element 0 of the array. Try your program on the following barcodes, three of which are valid. For the first barcode, the result from step 2 is 79 (0 + 9+0+8+ 4+ 0) * 3 + ( 7 + 4 + 0 + 0 + 5). 079400804501 024000162860 011110856807 051000138101 Noted that you need to include the below function: void calculateTotal(unsigned int [ ], unsigned int&, unsigned int& ); SAMPLE RUN: Enter 12 integers separated by blanks or S: 0 5 1 0 0 0 1 3 8 10 1 The sum of the digits in the odd-numbered positions: 10 The sum of the digits in the even-numbered positions: 9 The sum of the digits in the even-numbered positions and oddnumbered positions: 39 Entered Barcode: 051000138101 Result: Validated Barcode !

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 7PP: (Numerical) Using the srand() and rand() C++ library functions, fill an array of 1000 floating-point...
icon
Related questions
Question
100%
A barcode scanner for Universal Product Codes (UPCS) verifies the 12-digit code scanned by
comparing the code's largest digit (called a 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 position (the second, fourth...tenth
digits) and add this to the previous result.
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.
4. If the check digit matches the final digit of the 12-digit UPC, the UPC is assumed correct
By using C++ write a program that prompts the user to enter the 12 digits of a barcode separated by
space.
The program should store the digits in an integer array, 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 step 1 and 2 of the check-digit calculations. Note that the
"first" digit of the barcode will be store in element 0 of the array. Try your program on the
following barcodes, three of which are valid. For the first barcode, the result from step 2 is 79 ( 0
+ 9 + 0 + 8 + 4 + 0) * 3 + ( 7 + 4 + 0 + 0 + 5).
079400804501
0 2400016 28 60
01111085 6807
051000138101
Noted that you need to include the below function:
void calculateTotal(unsigned int [ ], unsigned int&, unsigned int& );
SAMPLE RUN:
Enter 12 integers separated by blanks or <return>S:
0 5 1 0 0 0 1 3 8 1 0 1
The sum of the digits in the odd-numbered positions: 10
The sum of the digits in the even-numbered positions: 9
The sum of the digits in the even-numbered positions and oddnumbered positions: 39
Entered Barcode:
051000138101
Result: Validated Barcode !
Transcribed Image Text:A barcode scanner for Universal Product Codes (UPCS) verifies the 12-digit code scanned by comparing the code's largest digit (called a 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 position (the second, fourth...tenth digits) and add this to the previous result. 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. 4. If the check digit matches the final digit of the 12-digit UPC, the UPC is assumed correct By using C++ write a program that prompts the user to enter the 12 digits of a barcode separated by space. The program should store the digits in an integer array, 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 step 1 and 2 of the check-digit calculations. Note that the "first" digit of the barcode will be store in element 0 of the array. Try your program on the following barcodes, three of which are valid. For the first barcode, the result from step 2 is 79 ( 0 + 9 + 0 + 8 + 4 + 0) * 3 + ( 7 + 4 + 0 + 0 + 5). 079400804501 0 2400016 28 60 01111085 6807 051000138101 Noted that you need to include the below function: void calculateTotal(unsigned int [ ], unsigned int&, unsigned int& ); SAMPLE RUN: Enter 12 integers separated by blanks or <return>S: 0 5 1 0 0 0 1 3 8 1 0 1 The sum of the digits in the odd-numbered positions: 10 The sum of the digits in the even-numbered positions: 9 The sum of the digits in the even-numbered positions and oddnumbered positions: 39 Entered Barcode: 051000138101 Result: Validated Barcode !
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Returning value from Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning